######################Data Analysis##############################################
## File name: food_conjoint_analysis.R
## Context:   Data Analysis for Conjoint Experiment by Fesenfeld et al. "Policy packaging can make food system transformation feasible"
## File prepared by: Lukas Fesenfeld
####################################################################

rm(list = ls())

################################ Load packages ################################ 
library(rlang)
library(vctrs)
library(Matrix)
library(ggthemes)
library(cjoint)
library(rlang)
library(ggplot2)
library(effects)
library(lme4)
library(data.table)
library(dplyr)
library(nFactors)
library(texreg)
library(tidyr)
library(forcats)
library(Rmisc)
library(cowplot)
library(ggpubr)
library(scales)
library(htmltools)

#Functions---------------

print.summary.amce <- function(x, digits=3, ...) {
  
  summary_result <- x
  
  
  #basic print for AMCE
  
  cat("------------------------------------------\n")
  
  cat("Average Marginal Component Effects (AMCE):\n")
  
  cat("------------------------------------------\n")
  
  print(summary_result$amce, digits=2, row.names=F)
  
  cat("---\n")
  
  cat(paste("Number of Obs. = ", summary_result$samplesize_estimates, sep=""))
  
  cat("\n")
  
  cat("---\n")   
  
  if (!is.null(summary_result$respondents)) {
    
    cat(paste("Number of Respondents = ", summary_result$respondents, sep=""))
    
    cat("\n")
    
    cat("---\n")
    
  } }



######################### Analysis ############################
baselines_base <- list()
baselines_base$attrib1_lab <- "3) No new tax"
baselines_base$attrib2_lab <- "2) General government budget"
baselines_base$attrib3_lab <- "4) No such rules"
baselines_base$attrib4_lab <- "3) No discounts"
baselines_base$attrib5_lab <- "3) Standards kept at current level"
baselines_base$attrib6_lab <- "3) No campaigns"
baselines_base$attrib7_lab <- "3) Keeping subsidies at current level"


attribute_list <- list()
attribute_list$attrib1_lab <- c("3) No new tax", "2) Increasing prices by 15%", "1) Increasing prices by 30%")
attribute_list$attrib2_lab <- c("2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes", "5) No tax revenues")
attribute_list$attrib3_lab <- c("1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", "4) No such rules")
attribute_list$attrib4_lab <- c("1) Reducing prices by 30%", "2) Reducing prices by 15%", "3) No discounts")
attribute_list$attrib5_lab <- c("1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level")
attribute_list$attrib6_lab <- c("1) Frequent campaigns", "2) Occasional campaigns", "3) No campaigns")
attribute_list$attrib7_lab <- c("1) Eliminating subsidies", "2) Halving subsidies", "3) Keeping subsidies at current level")
attribute_list$country <- c("CN", "DE", "US")


constraint_list <- list()

constraint_list[[1]] <- list()
constraint_list[[1]][["attrib1_lab"]] <- c("3) No new tax")
constraint_list[[1]][["attrib2_lab"]] <- c("2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes")

design <- cjoint::makeDesign(type="constraints", attribute.levels=attribute_list,
                     constraints=constraint_list)

df_conj$nonopolicy <- ifelse(df_conj$attrib1_lab=="3) No new tax" | df_conj$attrib3_lab=="4) No such rules" | df_conj$attrib4_lab=="3) No discounts" | df_conj$attrib5_lab=="3) Standards kept at current level" | df_conj$attrib6_lab=="3) No campaigns" | df_conj$attrib7_lab=="3) Keeping subsidies at current level", 0, 1)

#recoding rate variable into binary outcome: 0 = no support (rating 1-4), 1 = support (rating 5-7), i.e. people that are ambivalent (rating of 4 on 7-point Scale) about the policy package are coded as "no support"
df_conj$rate_bin <- ifelse(df_conj$rate == 1, 0,
                           ifelse(df_conj$rate == 2, 0, 
                                  ifelse(df_conj$rate == 3, 0,
                                         ifelse(df_conj$rate == 4, 0,
                                                ifelse(df_conj$rate == 5, 1,
                                                       ifelse(df_conj$rate == 6, 1,
                                                              ifelse(df_conj$rate == 7, 1, NA)))))))


df_conj_DE <- subset(df_conj, country == "DE")
df_conj_CN <- subset(df_conj, country == "CN")
df_conj_US <- subset(df_conj, country == "US")


################## Choice by country ###############
################## DE ###############

c_base_DE <- cjoint::amce(choice ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)

print(summary_result$amce, digits=digits, row.names=F)

c_attribute1 <- c(0, c_base_DE$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], c_base_DE$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, c_base_DE$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], c_base_DE$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, c_base_DE$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], c_base_DE$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],c_base_DE$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], c_base_DE$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, c_base_DE$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], c_base_DE$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],c_base_DE$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],c_base_DE$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, c_base_DE$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], c_base_DE$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], c_base_DE$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, c_base_DE$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], c_base_DE$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], c_base_DE$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, c_base_DE$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], c_base_DE$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, c_base_DE$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], c_base_DE$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, c_base_DE$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], c_base_DE$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, c_base_DE$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], c_base_DE$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, c_base_DE$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], c_base_DE$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, c_base_DE$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], c_base_DE$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, c_base_DE$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], c_base_DE$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, c_base_DE$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], c_base_DE$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_c_base_DE <- data.frame(c,s)
df_c_base_DE$att <- c(c_base_DE$attributes$attrib1lab[1], c_base_DE$attributes$attrib1lab[2:3], 
                        c_base_DE$attributes$attrib2lab[1], c_base_DE$attributes$attrib2lab[2:5],
                        c_base_DE$attributes$attrib3lab[4], c_base_DE$attributes$attrib3lab[3], c_base_DE$attributes$attrib3lab[2], c_base_DE$attributes$attrib3lab[1], 
                        c_base_DE$attributes$attrib4lab[3], c_base_DE$attributes$attrib4lab[2], c_base_DE$attributes$attrib4lab[1], 
                        c_base_DE$attributes$attrib5lab[3], c_base_DE$attributes$attrib5lab[2], c_base_DE$attributes$attrib5lab[1],
                        c_base_DE$attributes$attrib6lab[3], c_base_DE$attributes$attrib6lab[2], c_base_DE$attributes$attrib6lab[1],
                        c_base_DE$attributes$attrib7lab[3], c_base_DE$attributes$attrib7lab[2], c_base_DE$attributes$attrib7lab[1])



df_c_base_DE$att <- factor(df_c_base_DE$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))





################## CN ###############

c_base_CN <- amce(choice ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)


plot(c_base_CN)


c_attribute1 <- c(0, c_base_CN$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], c_base_CN$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, c_base_CN$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], c_base_CN$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, c_base_CN$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], c_base_CN$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],c_base_CN$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], c_base_CN$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, c_base_CN$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], c_base_CN$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],c_base_CN$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],c_base_CN$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, c_base_CN$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], c_base_CN$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], c_base_CN$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, c_base_CN$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], c_base_CN$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], c_base_CN$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, c_base_CN$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], c_base_CN$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, c_base_CN$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], c_base_CN$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, c_base_CN$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], c_base_CN$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, c_base_CN$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], c_base_CN$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, c_base_CN$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], c_base_CN$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, c_base_CN$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], c_base_CN$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, c_base_CN$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], c_base_CN$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, c_base_CN$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], c_base_CN$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_c_base_CN <- data.frame(c,s)
df_c_base_CN$att <- c(c_base_CN$attributes$attrib1lab[1], c_base_CN$attributes$attrib1lab[2:3], 
                      c_base_CN$attributes$attrib2lab[1], c_base_CN$attributes$attrib2lab[2:5],
                      c_base_CN$attributes$attrib3lab[4], c_base_CN$attributes$attrib3lab[3], c_base_CN$attributes$attrib3lab[2], c_base_CN$attributes$attrib3lab[1], 
                      c_base_CN$attributes$attrib4lab[3], c_base_CN$attributes$attrib4lab[2], c_base_CN$attributes$attrib4lab[1], 
                      c_base_CN$attributes$attrib5lab[3], c_base_CN$attributes$attrib5lab[2], c_base_CN$attributes$attrib5lab[1],
                      c_base_CN$attributes$attrib6lab[3], c_base_CN$attributes$attrib6lab[2], c_base_CN$attributes$attrib6lab[1],
                      c_base_CN$attributes$attrib7lab[3], c_base_CN$attributes$attrib7lab[2], c_base_CN$attributes$attrib7lab[1])
df_c_base_CN$att <- factor(df_c_base_CN$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))



################## US ###############

c_base_US <- amce(choice ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)


plot(c_base_US)


c_attribute1 <- c(0, c_base_US$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], c_base_US$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, c_base_US$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], c_base_US$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, c_base_US$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], c_base_US$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],c_base_US$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], c_base_US$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, c_base_US$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], c_base_US$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],c_base_US$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],c_base_US$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, c_base_US$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], c_base_US$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], c_base_US$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, c_base_US$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], c_base_US$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], c_base_US$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, c_base_US$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], c_base_US$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, c_base_US$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], c_base_US$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, c_base_US$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], c_base_US$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, c_base_US$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], c_base_US$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, c_base_US$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], c_base_US$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, c_base_US$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], c_base_US$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, c_base_US$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], c_base_US$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, c_base_US$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], c_base_US$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_c_base_US <- data.frame(c,s)
df_c_base_US$att <- c(c_base_US$attributes$attrib1lab[1], c_base_US$attributes$attrib1lab[2:3], 
                      c_base_US$attributes$attrib2lab[1], c_base_US$attributes$attrib2lab[2:5],
                      c_base_US$attributes$attrib3lab[4], c_base_US$attributes$attrib3lab[3], c_base_US$attributes$attrib3lab[2], c_base_US$attributes$attrib3lab[1], 
                      c_base_US$attributes$attrib4lab[3], c_base_US$attributes$attrib4lab[2], c_base_US$attributes$attrib4lab[1], 
                      c_base_US$attributes$attrib5lab[3], c_base_US$attributes$attrib5lab[2], c_base_US$attributes$attrib5lab[1],
                      c_base_US$attributes$attrib6lab[3], c_base_US$attributes$attrib6lab[2], c_base_US$attributes$attrib6lab[1],
                      c_base_US$attributes$attrib7lab[3], c_base_US$attributes$attrib7lab[2], c_base_US$attributes$attrib7lab[1])
df_c_base_US$att <- factor(df_c_base_US$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))



################## Rating by country, binary recoded scale ###############
################## DE ###############
df_conj_DE <- subset(df_conj, country == "DE")
r_bin_base_DE <- cjoint::amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)

summary(r_bin_base_DE)

plot(r_bin_base_DE)


c_attribute1 <- c(0, r_bin_base_DE$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], r_bin_base_DE$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, r_bin_base_DE$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], r_bin_base_DE$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, r_bin_base_DE$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_bin_base_DE$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],r_bin_base_DE$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], r_bin_base_DE$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, r_bin_base_DE$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_bin_base_DE$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],r_bin_base_DE$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],r_bin_base_DE$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, r_bin_base_DE$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], r_bin_base_DE$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], r_bin_base_DE$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, r_bin_base_DE$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], r_bin_base_DE$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], r_bin_base_DE$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, r_bin_base_DE$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], r_bin_base_DE$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, r_bin_base_DE$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], r_bin_base_DE$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, r_bin_base_DE$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_bin_base_DE$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, r_bin_base_DE$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_bin_base_DE$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, r_bin_base_DE$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], r_bin_base_DE$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, r_bin_base_DE$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], r_bin_base_DE$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, r_bin_base_DE$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], r_bin_base_DE$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, r_bin_base_DE$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], r_bin_base_DE$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_r_bin_base_DE <- data.frame(c,s)
df_r_bin_base_DE$att <- c(r_bin_base_DE$attributes$attrib1lab[1], r_bin_base_DE$attributes$attrib1lab[2:3], 
                      r_bin_base_DE$attributes$attrib2lab[1], r_bin_base_DE$attributes$attrib2lab[2:5],
                      r_bin_base_DE$attributes$attrib3lab[4], r_bin_base_DE$attributes$attrib3lab[3], r_bin_base_DE$attributes$attrib3lab[2], r_bin_base_DE$attributes$attrib3lab[1], 
                      r_bin_base_DE$attributes$attrib4lab[3], r_bin_base_DE$attributes$attrib4lab[2], r_bin_base_DE$attributes$attrib4lab[1], 
                      r_bin_base_DE$attributes$attrib5lab[3], r_bin_base_DE$attributes$attrib5lab[2], r_bin_base_DE$attributes$attrib5lab[1],
                      r_bin_base_DE$attributes$attrib6lab[3], r_bin_base_DE$attributes$attrib6lab[2], r_bin_base_DE$attributes$attrib6lab[1],
                      r_bin_base_DE$attributes$attrib7lab[3], r_bin_base_DE$attributes$attrib7lab[2], r_bin_base_DE$attributes$attrib7lab[1])
df_r_bin_base_DE$att <- factor(df_r_bin_base_DE$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))



################## CN ###############

df_conj_CN <- subset(df_conj, country == "CN")
r_bin_base_CN <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)

summary(r_bin_base_CN)

plot(r_bin_base_CN)


c_attribute1 <- c(0, r_bin_base_CN$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], r_bin_base_CN$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, r_bin_base_CN$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], r_bin_base_CN$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, r_bin_base_CN$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_bin_base_CN$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],r_bin_base_CN$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], r_bin_base_CN$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, r_bin_base_CN$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_bin_base_CN$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],r_bin_base_CN$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],r_bin_base_CN$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, r_bin_base_CN$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], r_bin_base_CN$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], r_bin_base_CN$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, r_bin_base_CN$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], r_bin_base_CN$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], r_bin_base_CN$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, r_bin_base_CN$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], r_bin_base_CN$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, r_bin_base_CN$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], r_bin_base_CN$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, r_bin_base_CN$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_bin_base_CN$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, r_bin_base_CN$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_bin_base_CN$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, r_bin_base_CN$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], r_bin_base_CN$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, r_bin_base_CN$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], r_bin_base_CN$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, r_bin_base_CN$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], r_bin_base_CN$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, r_bin_base_CN$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], r_bin_base_CN$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_r_bin_base_CN <- data.frame(c,s)
df_r_bin_base_CN$att <- c(r_bin_base_CN$attributes$attrib1lab[1], r_bin_base_CN$attributes$attrib1lab[2:3], 
                      r_bin_base_CN$attributes$attrib2lab[1], r_bin_base_CN$attributes$attrib2lab[2:5],
                      r_bin_base_CN$attributes$attrib3lab[4], r_bin_base_CN$attributes$attrib3lab[3], r_bin_base_CN$attributes$attrib3lab[2], r_bin_base_CN$attributes$attrib3lab[1], 
                      r_bin_base_CN$attributes$attrib4lab[3], r_bin_base_CN$attributes$attrib4lab[2], r_bin_base_CN$attributes$attrib4lab[1], 
                      r_bin_base_CN$attributes$attrib5lab[3], r_bin_base_CN$attributes$attrib5lab[2], r_bin_base_CN$attributes$attrib5lab[1],
                      r_bin_base_CN$attributes$attrib6lab[3], r_bin_base_CN$attributes$attrib6lab[2], r_bin_base_CN$attributes$attrib6lab[1],
                      r_bin_base_CN$attributes$attrib7lab[3], r_bin_base_CN$attributes$attrib7lab[2], r_bin_base_CN$attributes$attrib7lab[1])
df_r_bin_base_CN$att <- factor(df_r_bin_base_CN$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))


################## US ###############

df_conj_US <- subset(df_conj, country == "US")
r_bin_base_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)

summary(r_bin_base_US)

plot(r_bin_base_US)


c_attribute1 <- c(0, r_bin_base_US$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], r_bin_base_US$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, r_bin_base_US$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], r_bin_base_US$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, r_bin_base_US$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_bin_base_US$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],r_bin_base_US$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], r_bin_base_US$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, r_bin_base_US$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_bin_base_US$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],r_bin_base_US$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],r_bin_base_US$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, r_bin_base_US$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], r_bin_base_US$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], r_bin_base_US$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, r_bin_base_US$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], r_bin_base_US$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], r_bin_base_US$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, r_bin_base_US$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], r_bin_base_US$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, r_bin_base_US$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], r_bin_base_US$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, r_bin_base_US$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_bin_base_US$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, r_bin_base_US$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_bin_base_US$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, r_bin_base_US$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], r_bin_base_US$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, r_bin_base_US$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], r_bin_base_US$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, r_bin_base_US$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], r_bin_base_US$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, r_bin_base_US$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], r_bin_base_US$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_r_bin_base_US <- data.frame(c,s)
df_r_bin_base_US$att <- c(r_bin_base_US$attributes$attrib1lab[1], r_bin_base_US$attributes$attrib1lab[2:3], 
                      r_bin_base_US$attributes$attrib2lab[1], r_bin_base_US$attributes$attrib2lab[2:5],
                      r_bin_base_US$attributes$attrib3lab[4], r_bin_base_US$attributes$attrib3lab[3], r_bin_base_US$attributes$attrib3lab[2], r_bin_base_US$attributes$attrib3lab[1], 
                      r_bin_base_US$attributes$attrib4lab[3], r_bin_base_US$attributes$attrib4lab[2], r_bin_base_US$attributes$attrib4lab[1], 
                      r_bin_base_US$attributes$attrib5lab[3], r_bin_base_US$attributes$attrib5lab[2], r_bin_base_US$attributes$attrib5lab[1],
                      r_bin_base_US$attributes$attrib6lab[3], r_bin_base_US$attributes$attrib6lab[2], r_bin_base_US$attributes$attrib6lab[1],
                      r_bin_base_US$attributes$attrib7lab[3], r_bin_base_US$attributes$attrib7lab[2], r_bin_base_US$attributes$attrib7lab[1])
df_r_bin_base_US$att <- factor(df_r_bin_base_US$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))

################## Rating by country, 7-point scale ###############
################## DE ###############
df_conj_DE <- subset(df_conj, country == "DE")
r_base_DE <- amce(rate ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)

summary(r_base_DE)

plot(r_base_DE)


c_attribute1 <- c(0, r_base_DE$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], r_base_DE$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, r_base_DE$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], r_base_DE$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, r_base_DE$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_base_DE$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],r_base_DE$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], r_base_DE$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, r_base_DE$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_base_DE$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],r_base_DE$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],r_base_DE$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, r_base_DE$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], r_base_DE$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], r_base_DE$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, r_base_DE$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], r_base_DE$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], r_base_DE$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, r_base_DE$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], r_base_DE$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, r_base_DE$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], r_base_DE$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, r_base_DE$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_base_DE$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, r_base_DE$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_base_DE$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, r_base_DE$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], r_base_DE$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, r_base_DE$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], r_base_DE$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, r_base_DE$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], r_base_DE$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, r_base_DE$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], r_base_DE$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_r_base_DE <- data.frame(c,s)
df_r_base_DE$att <- c(r_base_DE$attributes$attrib1lab[1], r_base_DE$attributes$attrib1lab[2:3], 
                      r_base_DE$attributes$attrib2lab[1], r_base_DE$attributes$attrib2lab[2:5],
                      r_base_DE$attributes$attrib3lab[4], r_base_DE$attributes$attrib3lab[3], r_base_DE$attributes$attrib3lab[2], r_base_DE$attributes$attrib3lab[1], 
                      r_base_DE$attributes$attrib4lab[3], r_base_DE$attributes$attrib4lab[2], r_base_DE$attributes$attrib4lab[1], 
                      r_base_DE$attributes$attrib5lab[3], r_base_DE$attributes$attrib5lab[2], r_base_DE$attributes$attrib5lab[1],
                      r_base_DE$attributes$attrib6lab[3], r_base_DE$attributes$attrib6lab[2], r_base_DE$attributes$attrib6lab[1],
                      r_base_DE$attributes$attrib7lab[3], r_base_DE$attributes$attrib7lab[2], r_base_DE$attributes$attrib7lab[1])
df_r_base_DE$att <- factor(df_r_base_DE$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))


################## CN ###############

df_conj_CN <- subset(df_conj, country == "CN")
r_base_CN <- amce(rate ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)

summary(r_base_CN)

plot(r_base_CN)


c_attribute1 <- c(0, r_base_CN$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], r_base_CN$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, r_base_CN$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], r_base_CN$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, r_base_CN$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_base_CN$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],r_base_CN$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], r_base_CN$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, r_base_CN$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_base_CN$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],r_base_CN$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],r_base_CN$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, r_base_CN$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], r_base_CN$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], r_base_CN$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, r_base_CN$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], r_base_CN$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], r_base_CN$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, r_base_CN$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], r_base_CN$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, r_base_CN$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], r_base_CN$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, r_base_CN$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_base_CN$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, r_base_CN$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_base_CN$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, r_base_CN$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], r_base_CN$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, r_base_CN$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], r_base_CN$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, r_base_CN$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], r_base_CN$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, r_base_CN$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], r_base_CN$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_r_base_CN <- data.frame(c,s)
df_r_base_CN$att <- c(r_base_CN$attributes$attrib1lab[1], r_base_CN$attributes$attrib1lab[2:3], 
                      r_base_CN$attributes$attrib2lab[1], r_base_CN$attributes$attrib2lab[2:5],
                      r_base_CN$attributes$attrib3lab[4], r_base_CN$attributes$attrib3lab[3], r_base_CN$attributes$attrib3lab[2], r_base_CN$attributes$attrib3lab[1], 
                      r_base_CN$attributes$attrib4lab[3], r_base_CN$attributes$attrib4lab[2], r_base_CN$attributes$attrib4lab[1], 
                      r_base_CN$attributes$attrib5lab[3], r_base_CN$attributes$attrib5lab[2], r_base_CN$attributes$attrib5lab[1],
                      r_base_CN$attributes$attrib6lab[3], r_base_CN$attributes$attrib6lab[2], r_base_CN$attributes$attrib6lab[1],
                      r_base_CN$attributes$attrib7lab[3], r_base_CN$attributes$attrib7lab[2], r_base_CN$attributes$attrib7lab[1])
df_r_base_CN$att <- factor(df_r_base_CN$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))

################## US ###############

df_conj_US <- subset(df_conj, country == "US")
r_base_US <- amce(rate ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US, 
                  cluster=TRUE, respondent.id="id", 
                  design=design, baselines = baselines_base)

summary(r_base_US)

plot(r_base_US)


c_attribute1 <- c(0, r_base_US$estimates$attrib1lab["AMCE","attrib1lab2Increasingpricesby15"], r_base_US$estimates$attrib1lab["AMCE","attrib1lab1Increasingpricesby30"])
s_attribute1 <- c(0, r_base_US$estimates$attrib1lab["Std. Error","attrib1lab2Increasingpricesby15"], r_base_US$estimates$attrib1lab["Std. Error","attrib1lab1Increasingpricesby30"])
c_attribute2 <- c(0, r_base_US$estimates$attrib2lab["AMCE","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_base_US$estimates$attrib2lab["AMCE","attrib2lab3Publicprogramsforlowincomehouseholds"],r_base_US$estimates$attrib2lab["AMCE","attrib2lab4Reduceincometaxes"], r_base_US$estimates$attrib2lab["AMCE","attrib2lab5Notaxrevenues"])
s_attribute2 <- c(0, r_base_US$estimates$attrib2lab["Std. Error","attrib2lab1Publicenvironmentalandclimateprotectionprograms"], r_base_US$estimates$attrib2lab["Std. Error","attrib2lab3Publicprogramsforlowincomehouseholds"],r_base_US$estimates$attrib2lab["Std. Error","attrib2lab4Reduceincometaxes"],r_base_US$estimates$attrib2lab["Std. Error","attrib2lab5Notaxrevenues"])
c_attribute3 <- c(0, r_base_US$estimates$attrib3lab["AMCE","attrib3lab3Atleast25vegetarianmeals"], r_base_US$estimates$attrib3lab["AMCE","attrib3lab2Atleast50vegetarianmeals"], r_base_US$estimates$attrib3lab["AMCE","attrib3lab1Atleast75vegetarianmeals"])
s_attribute3 <- c(0, r_base_US$estimates$attrib3lab["Std. Error","attrib3lab3Atleast25vegetarianmeals"], r_base_US$estimates$attrib3lab["Std. Error","attrib3lab2Atleast50vegetarianmeals"], r_base_US$estimates$attrib3lab["Std. Error","attrib3lab1Atleast75vegetarianmeals"])
c_attribute4 <- c(0, r_base_US$estimates$attrib4lab["AMCE","attrib4lab2Reducingpricesby15"], r_base_US$estimates$attrib4lab["AMCE","attrib4lab1Reducingpricesby30"])
s_attribute4 <- c(0, r_base_US$estimates$attrib4lab["Std. Error","attrib4lab2Reducingpricesby15"], r_base_US$estimates$attrib4lab["Std. Error","attrib4lab1Reducingpricesby30"])
c_attribute5 <- c(0, r_base_US$estimates$attrib5lab["AMCE","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_base_US$estimates$attrib5lab["AMCE","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
s_attribute5 <- c(0, r_base_US$estimates$attrib5lab["Std. Error","attrib5lab2Stringentlimitsonantibioticschemicalslargecages"], r_base_US$estimates$attrib5lab["Std. Error","attrib5lab1\tOrganicpracticesnoantibioticschemicalsnocages"])
c_attribute6 <- c(0, r_base_US$estimates$attrib6lab["AMCE","attrib6lab2Occasionalcampaigns"], r_base_US$estimates$attrib6lab["AMCE","attrib6lab1Frequentcampaigns"])
s_attribute6 <- c(0, r_base_US$estimates$attrib6lab["Std. Error","attrib6lab2Occasionalcampaigns"], r_base_US$estimates$attrib6lab["Std. Error","attrib6lab1Frequentcampaigns"])
c_attribute7 <- c(0, r_base_US$estimates$attrib7lab["AMCE","attrib7lab2Halvingsubsidies"], r_base_US$estimates$attrib7lab["AMCE","attrib7lab1Eliminatingsubsidies"])
s_attribute7 <- c(0, r_base_US$estimates$attrib7lab["Std. Error","attrib7lab2Halvingsubsidies"], r_base_US$estimates$attrib7lab["Std. Error","attrib7lab1Eliminatingsubsidies"])


c <- c(c_attribute1, c_attribute2, c_attribute3, c_attribute4, c_attribute5, c_attribute6, c_attribute7)
s <- c(s_attribute1, s_attribute2, s_attribute3, s_attribute4, s_attribute5, s_attribute6, s_attribute7)

df_r_base_US <- data.frame(c,s)
df_r_base_US$att <- c(r_base_US$attributes$attrib1lab[1], r_base_US$attributes$attrib1lab[2:3], 
                      r_base_US$attributes$attrib2lab[1], r_base_US$attributes$attrib2lab[2:5],
                      r_base_US$attributes$attrib3lab[4], r_base_US$attributes$attrib3lab[3], r_base_US$attributes$attrib3lab[2], r_base_US$attributes$attrib3lab[1], 
                      r_base_US$attributes$attrib4lab[3], r_base_US$attributes$attrib4lab[2], r_base_US$attributes$attrib4lab[1], 
                      r_base_US$attributes$attrib5lab[3], r_base_US$attributes$attrib5lab[2], r_base_US$attributes$attrib5lab[1],
                      r_base_US$attributes$attrib6lab[3], r_base_US$attributes$attrib6lab[2], r_base_US$attributes$attrib6lab[1],
                      r_base_US$attributes$attrib7lab[3], r_base_US$attributes$attrib7lab[2], r_base_US$attributes$attrib7lab[1])
df_r_base_US$att <- factor(df_r_base_US$att, levels = c(rev(c("3Nonewtax", "2Increasingpricesby15", "1Increasingpricesby30",
                                                              "2Generalgovernmentbudget", "1Publicenvironmentalandclimateprotectionprograms", "3Publicprogramsforlowincomehouseholds", "4Reduceincometaxes", "5Notaxrevenues",
                                                              "4Nosuchrules", "3Atleast25vegetarianmeals", "2Atleast50vegetarianmeals", "1Atleast75vegetarianmeals", 
                                                              "3Nodiscounts", "2Reducingpricesby15", "1Reducingpricesby30", 
                                                              "3Standardskeptatcurrentlevel", "2Stringentlimitsonantibioticschemicalslargecages", "1\tOrganicpracticesnoantibioticschemicalsnocages",
                                                              "3Nocampaigns", "2Occasionalcampaigns", "1Frequentcampaigns", 
                                                              "3Keepingsubsidiesatcurrentlevel", "2Halvingsubsidies", "1Eliminatingsubsidies"))),
                           labels = c(rev(c("Baseline:\nNo new tax", "15% higher\nprices", "30% higher\nprices", 
                                            "Baseline:\nGeneral government budget", "Public environmental and\nclimate protection programs", "Public programs for\nlow-income households", "Reduce\nincome taxes", "No tax revenues",
                                            "Baseline:\nNo such rules", "25%\nveg. meals", "50%\nveg. meals", "75%\nveg. meals", 
                                            "Baseline:\nNo increase of support", "15% lower\nprices", "30% lower\nprices", 
                                            "Baseline:\nStandards kept at current level", "Higher\nstandards", "Organic\nstandards", 
                                            "Baseline:\nNo campaigns", "Occasional\ncampaigns", "Frequent\ncampaigns", 
                                            "Baseline:\nKeeping subsidies at current level", "Halving\nsubsidies", "Eliminating\nsubsidies"))))


#######Robustness Check Analyses###############

df_conj$grp_age <- as.factor(df_conj$age_grp)
df_conj$educ <- as.factor(df_conj$educ)
df_conj$incgrp <- as.factor(df_conj$incgrp)


##################Including sociodemographic variables and frames rating by country, binary recoded scale ###############
attribute_list$gender <- c("female", "male")
attribute_list$grp_age <- c("18-24", "25-34", "35-44", "45-54", "55-64", "65+")
attribute_list$educ <- as.factor(c("Low", "Medium", "High"))
attribute_list$Food_ <- c("Control", "Animal Welfare", "Global Climate", "Local Environment", "Personal Health")
attribute_list$incgrp <- as.factor(c("1st Quintile", "2nd Quintile", "3rd Quintile", "4th Quintile", "5th Quintile"))


################## DE ###############


r_bin_base_control_DE <- amce(rate_bin ~ attrib1_lab+  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                        attrib5_lab +  attrib6_lab +  attrib7_lab +Food_ +grp_age+incgrp+gender+educ , data = df_conj_DE, 
                      cluster=TRUE, respondent.id="id", 
                      design=design,
                       baselines = baselines_base)

summary(r_bin_base_control_DE)
plot(r_bin_base_control_DE)


################## CN ###############

r_bin_base_control_CN <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                        attrib5_lab +  attrib6_lab +  attrib7_lab+Food_ +grp_age+incgrp+gender+educ , data = df_conj_CN, 
                      cluster=TRUE, respondent.id="id",design=design, 
                       baselines = baselines_base)

summary(r_bin_base_control_CN)
plot(r_bin_base_control_CN)


################## US ###############

r_bin_base_control_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                        attrib5_lab +  attrib6_lab +  attrib7_lab+Food_ +grp_age+incgrp+gender+educ , data = df_conj_US, 
                      cluster=TRUE, respondent.id="id",design=design, 
                       baselines = baselines_base)

summary(r_bin_base_control_US)
plot(r_bin_base_control_US)


##################Restricting CN, DE and US sample to meat/fish and no meat/fish eaters  ###############

################## CN ###############

df_conj_CN_robust_meat <- subset(df_conj, country == "CN" & meat_fish =="Meat Eater")
df_conj_CN_robust_no_meat <- subset(df_conj, country == "CN" & meat_fish =="Vegetarian/Vegan")

r_bin_base_robust_meat_CN <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN_robust_meat,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_CN)
plot(r_bin_base_robust_meat_CN)

r_bin_base_robust_no_meat_CN <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                     attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN_robust_no_meat,  
                                   cluster=TRUE, respondent.id="id", 
                                   design=design, baselines = baselines_base)

summary(r_bin_base_robust_no_meat_CN)
plot(r_bin_base_robust_no_meat_CN)

################## DE ###############

df_conj_DE_robust_meat <- subset(df_conj, country == "DE" & meat_fish =="Meat Eater")
df_conj_DE_robust_no_meat <- subset(df_conj, country == "DE" & meat_fish =="Vegetarian/Vegan")

r_bin_base_robust_meat_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_meat,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_DE)
plot(r_bin_base_robust_meat_DE)

r_bin_base_robust_no_meat_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                       attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_no_meat,  
                                     cluster=TRUE, respondent.id="id", 
                                     design=design, baselines = baselines_base)

summary(r_bin_base_robust_no_meat_DE)
plot(r_bin_base_robust_no_meat_DE)

################## US ###############

df_conj_US_robust_meat <- subset(df_conj, country == "US" & meat_fish =="Meat Eater")
df_conj_US_robust_no_meat <- subset(df_conj, country == "US" & meat_fish =="Vegetarian/Vegan")

r_bin_base_robust_meat_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_meat,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_US)
plot(r_bin_base_robust_meat_US)

r_bin_base_robust_no_meat_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                       attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_no_meat,  
                                     cluster=TRUE, respondent.id="id", 
                                     design=design, baselines = baselines_base)

summary(r_bin_base_robust_no_meat_US)
plot(r_bin_base_robust_no_meat_US)

##################Restricting CN, DE and US sample by median split of meat/fish consumption ###############

################## CN ###############

df_conj_CN_robust_meat_low <- subset(df_conj, country == "CN" & weekmeat <median(df_conj$weekmeat [df_conj$country == "CN"]))
df_conj_CN_robust_meat_high <- subset(df_conj, country == "CN" & weekmeat >median(df_conj$weekmeat [df_conj$country == "CN"]))

r_bin_base_robust_meat_low_CN <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN_robust_meat_low,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_low_CN)
plot(r_bin_base_robust_meat_low_CN)

r_bin_base_robust_meat_high_CN <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                        attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN_robust_meat_high,  
                                      cluster=TRUE, respondent.id="id", 
                                      design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_high_CN)
plot(r_bin_base_robust_meat_high_CN)

################## DE ###############

df_conj_DE_robust_meat_low <- subset(df_conj, country == "DE" & weekmeat <median(df_conj$weekmeat [df_conj$country == "DE"]))
df_conj_DE_robust_meat_high <- subset(df_conj, country == "DE" & weekmeat >median(df_conj$weekmeat [df_conj$country == "DE"]))

r_bin_base_robust_meat_low_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                        attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_meat_low,  
                                      cluster=TRUE, respondent.id="id", 
                                      design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_low_DE)
plot(r_bin_base_robust_meat_low_DE)

r_bin_base_robust_meat_high_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                         attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_meat_high,  
                                       cluster=TRUE, respondent.id="id", 
                                       design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_high_DE)
plot(r_bin_base_robust_meat_high_DE)

################## US ###############

df_conj_US_robust_meat_low <- subset(df_conj, country == "US" & weekmeat <median(df_conj$weekmeat [df_conj$country == "US"]))
df_conj_US_robust_meat_high <- subset(df_conj, country == "US" & weekmeat >median(df_conj$weekmeat [df_conj$country == "US"]))

r_bin_base_robust_meat_low_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                        attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_meat_low,  
                                      cluster=TRUE, respondent.id="id", 
                                      design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_low_US)
plot(r_bin_base_robust_meat_low_US)

r_bin_base_robust_meat_high_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                         attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_meat_high,  
                                       cluster=TRUE, respondent.id="id", 
                                       design=design, baselines = baselines_base)

summary(r_bin_base_robust_meat_high_US)
plot(r_bin_base_robust_meat_high_US)


##################Restricting DE and US sample to left/right median splitted sample to test for potential ideology effects  ###############

################## DE ###############
df_conj_DE_robust_left <- subset(df_conj, country == "DE" & left_right <median(df_conj$left_right [df_conj$country == "DE"]))
df_conj_DE_robust_right <- subset(df_conj, country == "DE" & left_right >median(df_conj$left_right [df_conj$country == "DE"]))

r_bin_base_robust_left_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_left,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_left_DE)
plot(r_bin_base_robust_left_DE)

r_bin_base_robust_right_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_right,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_right_DE)
plot(r_bin_base_robust_right_DE)

################## US ###############

df_conj_US_robust_left <- subset(df_conj, country == "US" & left_right <median(df_conj$left_right [df_conj$country == "US"]))
df_conj_US_robust_right <- subset(df_conj, country == "US" & left_right >median(df_conj$left_right [df_conj$country == "US"]))

r_bin_base_robust_left_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_left,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_left_US)
plot(r_bin_base_robust_left_US)

r_bin_base_robust_right_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                     attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_right,  
                                   cluster=TRUE, respondent.id="id", 
                                   design=design, baselines = baselines_base)

summary(r_bin_base_robust_right_US)
plot(r_bin_base_robust_right_US)

##################Restricting DE and US sample by government intervention variable: median splitted sample to test for potential govern. intervention ideology effects  ###############
################## DE ###############

df_conj_DE_robust_too_much <- subset(df_conj, country == "DE" & government_int <median(df_conj$government_int [df_conj$country == "DE"]))
df_conj_DE_robust_too_little <- subset(df_conj, country == "DE" & government_int >median(df_conj$government_int [df_conj$country == "DE"]))

r_bin_base_robust_too_much_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                        attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_too_much,  
                                      cluster=TRUE, respondent.id="id", 
                                      design=design, baselines = baselines_base)

summary(r_bin_base_robust_too_much_DE)
plot(r_bin_base_robust_too_much_DE)

r_bin_base_robust_too_little_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                          attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_too_little,  
                                        cluster=TRUE, respondent.id="id", 
                                        design=design, baselines = baselines_base)

summary(r_bin_base_robust_too_little_DE)
plot(r_bin_base_robust_too_little_DE)

################## US ###############
df_conj_US_robust_too_much <- subset(df_conj, country == "US" & government_int <median(df_conj$government_int [df_conj$country == "US"]))
df_conj_US_robust_too_little <- subset(df_conj, country == "US" & government_int >median(df_conj$government_int [df_conj$country == "US"]))

r_bin_base_robust_too_much_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_too_much,  
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_too_much_US)
plot(r_bin_base_robust_too_much_US)

r_bin_base_robust_too_little_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                     attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_too_little,  
                                   cluster=TRUE, respondent.id="id", 
                                   design=design, baselines = baselines_base)

summary(r_bin_base_robust_too_little_US)
plot(r_bin_base_robust_too_little_US)

##################Restricting US sample by party ID variable: splitted sample to test for potential partyID effects  ###############
################## US ###############
df_conj_US_robust_Republican <- subset(df_conj, country == "US" & partyID == "Republican")
df_conj_US_robust_Democrat <- subset(df_conj, country == "US" & partyID == "Democrat")
df_conj_US_robust_Independent <- subset(df_conj, country == "US" & partyID == "Independent")

r_bin_base_robust_Republican_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                        attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_Republican,  
                                      cluster=TRUE, respondent.id="id", 
                                      design=design, baselines = baselines_base)

summary(r_bin_base_robust_Republican_US)
plot(r_bin_base_robust_Republican_US)

r_bin_base_robust_Democrat_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                          attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_Democrat,  
                                        cluster=TRUE, respondent.id="id", 
                                        design=design, baselines = baselines_base)

summary(r_bin_base_robust_Democrat_US)
plot(r_bin_base_robust_Democrat_US)

r_bin_base_robust_Independent_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                          attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_Independent,  
                                        cluster=TRUE, respondent.id="id", 
                                        design=design, baselines = baselines_base)

summary(r_bin_base_robust_Independent_US)
plot(r_bin_base_robust_Independent_US)

##################Restricting DE and US sample to high-income sample to compare to CN sample rating by country, binary recoded scale ###############

################## DE ###############
df_conj_DE_robust_high <- subset(df_conj, country == "DE" & incgrp =="4th Quintile"|country == "DE"&incgrp =="5th Quintile")

table(df_conj_DE_robust_high$incgrp, df_conj_DE_robust_high$country)
r_bin_base_robust_high_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                        attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_high, 
                      cluster=TRUE, respondent.id="id", 
                      design=design, baselines = baselines_base)

summary(r_bin_base_robust_high_DE)

df_conj_DE_robust_low <- subset(df_conj, country == "DE" & incgrp =="1st Quintile"|country == "DE"&incgrp =="2nd Quintile")

table(df_conj_DE_robust_low$incgrp, df_conj_DE_robust_low$country)
r_bin_base_robust_low_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                               attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust_low, 
                             cluster=TRUE, respondent.id="id", 
                             design=design, baselines = baselines_base)

summary(r_bin_base_robust_low_DE)


################## US ###############

df_conj_US_robust_high <- subset(df_conj, country == "US" & incgrp =="4th Quintile"|country == "US"&incgrp =="5th Quintile")

table(df_conj_US_robust_high$incgrp)

r_bin_base_robust_high_US<- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                        attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_high, 
                      cluster=TRUE, respondent.id="id", 
                      design=design, baselines = baselines_base)

summary(r_bin_base_robust_high_US)

df_conj_US_robust_low <- subset(df_conj, country == "US" & incgrp =="1st Quintile"|country == "US"&incgrp =="2nd Quintile")

table(df_conj_US_robust_low$incgrp)

r_bin_base_robust_low_US<- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                   attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust_low, 
                                 cluster=TRUE, respondent.id="id", 
                                 design=design, baselines = baselines_base)

summary(r_bin_base_robust_low_US)


########################################## Restricting sample to observations without any logical inconsistencies in conjoint responses (i.e. dropping those observations for which the chosen policy-package is rated lower than the non-chosen package) #####################################

df_conj$rate_A_n [df_conj$policy =="A"]<- as.numeric(as.factor(df_conj$rate_A[df_conj$policy =="A"]))
df_conj$rate_B_n[df_conj$policy =="B"] <- as.numeric(as.factor(df_conj$rate_B [df_conj$policy =="B"]))


vec1 <- df_conj$rate_A_n[1:nrow(df_conj)]
vec2 <- df_conj$rate_B_n[1:nrow(df_conj)]
for (i in 1:nrow(df_conj)) {
  if (is.na(df_conj$rate_A_n[i])) {
    
    vec1[i] <- df_conj$rate_A_n[i-1] 
  }
  if (is.na(df_conj$rate_B_n[i])) {
    
    vec2[i] <- df_conj$rate_B_n[i+1]
  }
}
diff <- vec1 - vec2
diff[seq(2, length(diff), 2)] <- diff[seq(2, length(diff), 2)] * -1

df_conj$rate_diff <- diff


df_conj$logic <- ifelse (df_conj$rate_diff>=0 & df_conj$choice ==1|df_conj$rate_diff<=0& df_conj$choice ==0, 1, 0)

table(df_conj$logic, df_conj$country)


################## DE ###############
df_conj_DE_robust <- subset(df_conj, country == "DE" & logic ==1)

r_bin_base_robust_DE <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                                    attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_DE_robust, 
                                  cluster=TRUE, respondent.id="id", 
                                  design=design, baselines = baselines_base)

summary(r_bin_base_robust_DE)

################## CN ###############
df_conj_CN_robust <- subset(df_conj, country == "CN" & logic ==1 )

r_bin_base_robust_CN <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                               attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_CN_robust, 
                             cluster=TRUE, respondent.id="id", 
                             design=design, baselines = baselines_base)

summary(r_bin_base_robust_CN)

################## US ###############
df_conj_US_robust <- subset(df_conj, country == "US" & logic==1 )

r_bin_base_robust_US <- amce(rate_bin ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                               attrib5_lab +  attrib6_lab +  attrib7_lab, data = df_conj_US_robust, 
                             cluster=TRUE, respondent.id="id", 
                             design=design, baselines = baselines_base)

summary(r_bin_base_robust_US)


########################################## Paper graphs #####################################
#Figure 1 and 2--------

install.packages("cregg")
library(cregg)

#conjoint graph by country, binary recoded scale

df_countries <- rbind(df_r_bin_base_US, df_r_bin_base_CN, df_r_bin_base_DE)
df_countries$ctr <- rep(c("USA", "China", "Germany"), each=nrow(df_r_bin_base_US))
df_countries$policy <- ifelse(df_countries$att == "Baseline: No new tax" |  df_countries$att == "15% higher\nprices" |  df_countries$att == "30% higher\nprices", "1", ifelse(
  df_countries$att == "Baseline:\nGeneral government budget" | df_countries$att == "Public environmental and\nclimate protection programs" | df_countries$att == "Public programs for\nlow-income households" | df_countries$att == "Reduce\nincome taxes" | df_countries$att == "No tax revenues", "2", ifelse(
    df_countries$att == "Baseline:\nKeeping subsidies at current level" | df_countries$att == "Halving\nsubsidies" | df_countries$att == "Eliminating\nsubsidies", "3", ifelse(
      df_countries$att == "Baseline:\nNo such rules" | df_countries$att == "25%\nveg. meals" | df_countries$att == "50%\nveg. meals" | df_countries$att == "75%\nveg. meals", "5", ifelse(
        df_countries$att == "Baseline:\nStandards kept at current level" | df_countries$att == "Higher\nstandards" | df_countries$att == "Organic\nstandards", "4", ifelse(
          df_countries$att == "Baseline:\nNo campaigns" | df_countries$att == "Occasional\ncampaigns" | df_countries$att == "Frequent\ncampaigns", "6", ifelse(
            df_countries$att == "Baseline:\nNo increase of support" | df_countries$att == "15% lower\nprices" | df_countries$att == "30% lower\nprices", "7",
            "8")))))))
df_countries$policy = factor(df_countries$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies",  "Standards","Regulations", "Campaigns", "Discounts", "Other"))
#df_countries$grp <- rep(c("Rating", "Rating", "Rating", "Choice", "Choice", "Choice"), each=nrow(df_r_base_US))


levels(df_countries$policy)


df_countries  <- df_countries[df_countries$att != "Baseline:\nNo increase of support" & df_countries$att != "Baseline:\nNo campaigns" & df_countries$att != "Baseline:\nStandards kept at current level" & df_countries$att != "Baseline:\nNo such rules"&df_countries$att != "Baseline:\nKeeping subsidies at current level"&df_countries$att != "Baseline:\nGeneral government budget" &df_countries$att != "Baseline:\nNo new tax", ]
df_countries  <- df_countries[complete.cases(df_countries), ]

df_countries_w_earmarking<- subset(df_countries,policy !="Earmarking")
df_countries_only_earmarking<- subset(df_countries,policy =="Earmarking")



cntrs_fig1 <- ggplot(df_countries_w_earmarking, 
                        aes(x = att, y = c,
                            group = ctr, shape = ctr, colour = ctr)) +
  facet_wrap(~ policy, scales = "free_y") +
  geom_pointrange(aes(min = c - 1.95 * s, max = c + 1.95 * s), position = position_dodge(width = 1/2), size = 1.2) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  ylab("\nAverage marginal component effects on respondents' support share") +
  xlab("Attribute Value") +
  theme_minimal() +
  coord_flip()  +
  scale_color_manual(name="Country", values=c("#e66101", "#5e3c99", "#b2abd2")) +
  scale_shape_discrete(name="Country") + 
  theme(plot.title = element_text(size = 24, face = "bold"),strip.text.x = element_text(size=24, face ="bold"),axis.text.x =element_text(size=24, face ="bold"),axis.text.y =element_text(size=24, face ="bold"), axis.title.y = element_text(size = 24, face ="bold"), axis.title.x = element_text(size = 24, face ="bold"))+
  theme (legend.position = "bottom", legend.text =element_text(size=24, face ="bold"), legend.title = element_text(size=24, face ="bold"))


cntrs_fig2 <- ggplot(df_countries_only_earmarking, 
                        aes(x = att, y = c,
                            group = ctr, shape = ctr, colour = ctr)) +
  facet_wrap(~ policy, scales = "free_y") +
  geom_pointrange(aes(min = c - 1.95 * s, max = c + 1.95 * s), position = position_dodge(width = 1/2), size = 1.2) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  ylab("\nAverage marginal component effects on respondents' support share") +
  xlab("Attribute Value") +
  theme_minimal() +
  coord_flip()  +
  scale_color_manual(name="Country", values=c("#e66101", "#5e3c99", "#b2abd2")) +
  scale_shape_discrete(name="Country") + 
  theme(plot.title = element_text(size = 24, face = "bold"),strip.text.x = element_text(size=24, face ="bold"),axis.text.x =element_text(size=24, face ="bold"),axis.text.y =element_text(size=24, face ="bold"), axis.title.y = element_text(size = 24, face ="bold"), axis.title.x = element_text(size = 24, face ="bold"))+
  theme (legend.position = "bottom", legend.text =element_text(size=24, face ="bold"), legend.title = element_text(size=24, face ="bold"))


ggsave(filename = ".fig1_binary_support_conjoint_countries.pdf", cntrs_fig1 , width = 22, height = 18, dpi=320)
ggsave(filename = ".fig1_binary_support_earmarking_conjoint_countries.pdf", cntrs_fig2 , width = 18, height = 14,dpi=320)

#conjoint graph by country, 7-point rating scale

df_countries <- rbind(df_r_base_US, df_r_base_CN, df_r_base_DE)
df_countries$ctr <- rep(c("USA", "China", "Germany"), each=nrow(df_r_base_US))
df_countries$policy <- ifelse(df_countries$att == "Baseline: No new tax" |  df_countries$att == "15% higher\nprices" |  df_countries$att == "30% higher\nprices", "1", ifelse(
  df_countries$att == "Baseline:\nGeneral government budget" | df_countries$att == "Public environmental and\nclimate protection programs" | df_countries$att == "Public programs for\nlow-income households" | df_countries$att == "Reduce\nincome taxes" | df_countries$att == "No tax revenues", "2", ifelse(
    df_countries$att == "Baseline:\nKeeping subsidies at current level" | df_countries$att == "Halving\nsubsidies" | df_countries$att == "Eliminating\nsubsidies", "3", ifelse(
      df_countries$att == "Baseline:\nNo such rules" | df_countries$att == "25%\nveg. meals" | df_countries$att == "50%\nveg. meals" | df_countries$att == "75%\nveg. meals", "5", ifelse(
        df_countries$att == "Baseline:\nStandards kept at current level" | df_countries$att == "Higher\nstandards" | df_countries$att == "Organic\nstandards", "4", ifelse(
          df_countries$att == "Baseline:\nNo campaigns" | df_countries$att == "Occasional\ncampaigns" | df_countries$att == "Frequent\ncampaigns", "6", ifelse(
            df_countries$att == "Baseline:\nNo increase of support" | df_countries$att == "15% lower\nprices" | df_countries$att == "30% lower\nprices", "7",
            "8")))))))
df_countries$policy = factor(df_countries$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies",  "Standards","Regulations", "Campaigns", "Discounts", "Other"))


levels(df_countries$policy)


df_countries  <- df_countries[df_countries$att != "Baseline:\nNo increase of support" & df_countries$att != "Baseline:\nNo campaigns" & df_countries$att != "Baseline:\nStandards kept at current level" & df_countries$att != "Baseline:\nNo such rules"&df_countries$att != "Baseline:\nKeeping subsidies at current level"&df_countries$att != "Baseline:\nGeneral government budget" &df_countries$att != "Baseline:\nNo new tax", ]
df_countries  <- df_countries[complete.cases(df_countries), ]

df_countries_w_earmarking<- subset(df_countries,policy !="Earmarking")
df_countries_only_earmarking<- subset(df_countries,policy =="Earmarking")



cntrs_fig1a <- ggplot(df_countries_w_earmarking, 
                     aes(x = att, y = c,
                         group = ctr, shape = ctr, colour = ctr)) +
  facet_wrap(~ policy, scales = "free_y") +
  geom_pointrange(aes(min = c - 1.95 * s, max = c + 1.95 * s), position = position_dodge(width = 1/2), size = 1.2) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  ylab("\nAverage Marginal Component Effects on Rated Support") +
  xlab("Attribute Value") +
  theme_minimal() +
  coord_flip()  +
  scale_color_manual(name="Country", values=c("#e66101", "#5e3c99", "#b2abd2")) +
  scale_shape_discrete(name="Country") + 
  theme(plot.title = element_text(size = 24, face = "bold"),,strip.text.x = element_text(size=24, face ="bold"),axis.text.x =element_text(size=24, face ="bold"),axis.text.y =element_text(size=24, face ="bold"), axis.title.y = element_text(size = 24, face ="bold"), axis.title.x = element_text(size = 24, face ="bold"))+
  theme (legend.position = "bottom", legend.text =element_text(size=24, face ="bold"), legend.title = element_text(size=24, face ="bold"))


cntrs_fig2a <- ggplot(df_countries_only_earmarking, 
                     aes(x = att, y = c,
                         group = ctr, shape = ctr, colour = ctr)) +
  facet_wrap(~ policy, scales = "free_y") +
  geom_pointrange(aes(min = c - 1.95 * s, max = c + 1.95 * s), position = position_dodge(width = 1/2), size = 1.2) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  ylab("\nAverage Marginal Component Effects on Rated Support") +
  xlab("Attribute Value") +
  theme_minimal() +
  coord_flip()  +
  scale_color_manual(name="Country", values=c("#e66101", "#5e3c99", "#b2abd2")) +
  scale_shape_discrete(name="Country") + 
  theme(plot.title = element_text(size = 24, face = "bold"),,strip.text.x = element_text(size=24, face ="bold"),axis.text.x =element_text(size=24, face ="bold"),axis.text.y =element_text(size=24, face ="bold"), axis.title.y = element_text(size = 24, face ="bold"), axis.title.x = element_text(size = 24, face ="bold"))+
  theme (legend.position = "bottom", legend.text =element_text(size=24, face ="bold"), legend.title = element_text(size=24, face ="bold"))


ggsave(filename = ".fig1a_rating_conjoint_countries.png", cntrs_fig1a , width = 22, height = 18)
ggsave(filename = ".fig1a_rating_earmarking_conjoint_countries.png", cntrs_fig2a , width = 18, height = 14)

#conjoint graph by country, choice outcome

df_countries <- rbind(df_c_base_US, df_c_base_CN, df_c_base_DE)
df_countries$ctr <- rep(c("USA", "China", "Germany"), each=nrow(df_c_base_US))
df_countries$policy <- ifelse(df_countries$att == "Baseline: No new tax" |  df_countries$att == "15% higher\nprices" |  df_countries$att == "30% higher\nprices", "1", ifelse(
  df_countries$att == "Baseline:\nGeneral government budget" | df_countries$att == "Public environmental and\nclimate protection programs" | df_countries$att == "Public programs for\nlow-income households" | df_countries$att == "Reduce\nincome taxes" | df_countries$att == "No tax revenues", "2", ifelse(
    df_countries$att == "Baseline:\nKeeping subsidies at current level" | df_countries$att == "Halving\nsubsidies" | df_countries$att == "Eliminating\nsubsidies", "3", ifelse(
      df_countries$att == "Baseline:\nNo such rules" | df_countries$att == "25%\nveg. meals" | df_countries$att == "50%\nveg. meals" | df_countries$att == "75%\nveg. meals", "5", ifelse(
        df_countries$att == "Baseline:\nStandards kept at current level" | df_countries$att == "Higher\nstandards" | df_countries$att == "Organic\nstandards", "4", ifelse(
          df_countries$att == "Baseline:\nNo campaigns" | df_countries$att == "Occasional\ncampaigns" | df_countries$att == "Frequent\ncampaigns", "6", ifelse(
            df_countries$att == "Baseline:\nNo increase of support" | df_countries$att == "15% lower\nprices" | df_countries$att == "30% lower\nprices", "7",
            "8")))))))
df_countries$policy = factor(df_countries$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies",  "Standards","Regulations", "Campaigns", "Discounts", "Other"))


levels(df_countries$policy)


df_countries  <- df_countries[df_countries$att != "Baseline:\nNo increase of support" & df_countries$att != "Baseline:\nNo campaigns" & df_countries$att != "Baseline:\nStandards kept at current level" & df_countries$att != "Baseline:\nNo such rules"&df_countries$att != "Baseline:\nKeeping subsidies at current level"&df_countries$att != "Baseline:\nGeneral government budget" &df_countries$att != "Baseline:\nNo new tax", ]
df_countries  <- df_countries[complete.cases(df_countries), ]

df_countries_w_earmarking<- subset(df_countries,policy !="Earmarking")
df_countries_only_earmarking<- subset(df_countries,policy =="Earmarking")



cntrs_fig1b <- ggplot(df_countries_w_earmarking, 
                      aes(x = att, y = c,
                          group = ctr, shape = ctr, colour = ctr)) +
  facet_wrap(~ policy, scales = "free_y") +
  geom_pointrange(aes(min = c - 1.95 * s, max = c + 1.95 * s), position = position_dodge(width = 1/2), size = 1.2) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  ylab("\nAverage Marginal Component Effects on Choice Probability") +
  xlab("Attribute Value") +
  theme_minimal() +
  coord_flip()  +
  scale_color_manual(name="Country", values=c("#e66101", "#5e3c99", "#b2abd2")) +
  scale_shape_discrete(name="Country") + 
  theme(plot.title = element_text(size = 24, face = "bold"),,strip.text.x = element_text(size=24, face ="bold"),axis.text.x =element_text(size=24, face ="bold"),axis.text.y =element_text(size=24, face ="bold"), axis.title.y = element_text(size = 24, face ="bold"), axis.title.x = element_text(size = 24, face ="bold"))+
  theme (legend.position = "bottom", legend.text =element_text(size=24, face ="bold"), legend.title = element_text(size=24, face ="bold"))


cntrs_fig2b <- ggplot(df_countries_only_earmarking, 
                      aes(x = att, y = c,
                          group = ctr, shape = ctr, colour = ctr)) +
  facet_wrap(~ policy, scales = "free_y") +
  geom_pointrange(aes(min = c - 1.95 * s, max = c + 1.95 * s), position = position_dodge(width = 1/2), size = 1.2) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  ylab("\nAverage Marginal Component Effects on Choice Probability") +
  xlab("Attribute Value") +
  theme_minimal() +
  coord_flip()  +
  scale_color_manual(name="Country", values=c("#e66101", "#5e3c99", "#b2abd2")) +
  scale_shape_discrete(name="Country") + 
  theme(plot.title = element_text(size = 24, face = "bold"),,strip.text.x = element_text(size=24, face ="bold"),axis.text.x =element_text(size=24, face ="bold"),axis.text.y =element_text(size=24, face ="bold"), axis.title.y = element_text(size = 24, face ="bold"), axis.title.x = element_text(size = 24, face ="bold"))+
  theme (legend.position = "bottom", legend.text =element_text(size=24, face ="bold"), legend.title = element_text(size=24, face ="bold"))


ggsave(filename = ".fig1b_choice_conjoint_countries.jpeg", cntrs_fig1b , width = 22, height = 18)
ggsave(filename = ".fig1b_choice_earmarking_conjoint_countries.jpeg", cntrs_fig2b , width = 18, height = 14)


################## Figure 4: Marginal Means by tax: rate_bin as DV ###############
#rate 0% DE

table(df_conj$attrib1_lab, df_conj$country)
taxmm0DE <- mm(subset(df_conj, country == "DE" & attrib1_lab %in% c("3) No new tax")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

taxmm0DE <- na.omit(taxmm0DE)
plot(taxmm0DE)

taxmm0DE$att <- factor(taxmm0DE$level, levels = c(rev(c("No new tax",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("No new tax",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm0DE$policy <- ifelse(taxmm0DE$att == "No new tax" |  taxmm0DE$att == "Increasing prices by 15%" |  taxmm0DE$att == "Increasing prices by 30%", "1", ifelse(
  taxmm0DE$att == "General\nbudget" | taxmm0DE$att == "Env. & climate\nprotection" | taxmm0DE$att == "Low-income\nhouseholds" | taxmm0DE$att == "Reduce\nincome taxes" | taxmm0DE$att == "No tax revenues", "2", ifelse(
    taxmm0DE$att == "Keep at\ncurrent level" | taxmm0DE$att == "Halving\nsubsidies" | taxmm0DE$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm0DE$att == "No\nsuch rules" | taxmm0DE$att == "75%\nveg. meals" | taxmm0DE$att == "50%\nveg. meals" | taxmm0DE$att == "25%\nveg. meals" , "4", ifelse(
        taxmm0DE$att == "Kept at\ncurrent level" | taxmm0DE$att == "Higher\nstandards" | taxmm0DE$att == "Organic\nstandards", "5", ifelse(
          taxmm0DE$att == "No\ncampaigns" | taxmm0DE$att == "Occasional\ncampaigns" | taxmm0DE$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm0DE$att == "No\ndiscounts" | taxmm0DE$att == "15% lower\nprices" | taxmm0DE$att == "30% lower\nprices", "6",
            "8")))))))

taxmm0DE$policy = factor(taxmm0DE$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))




#rate 15% DE

table(df_conj$attrib1_lab, df_conj$country)
taxmm15DE <- mm(subset(df_conj, country == "DE" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

taxmm15DE <- na.omit(taxmm15DE)
plot(taxmm15DE)

taxmm15DE$att <- factor(taxmm15DE$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("15% higher\nprices",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm15DE$policy <- ifelse(taxmm15DE$att == "No new tax" |  taxmm15DE$att == "15% higher\nprices" |  taxmm15DE$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15DE$att == "General\nbudget" | taxmm15DE$att == "Env. & climate\nprotection" | taxmm15DE$att == "Low-income\nhouseholds" | taxmm15DE$att == "Reduce\nincome taxes" | taxmm15DE$att == "No tax revenues", "2", ifelse(
    taxmm15DE$att == "Keep at\ncurrent level" | taxmm15DE$att == "Halving\nsubsidies" | taxmm15DE$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm15DE$att == "No\nsuch rules" | taxmm15DE$att == "75%\nveg. meals" | taxmm15DE$att == "50%\nveg. meals" | taxmm15DE$att == "25%\nveg. meals" , "4", ifelse(
        taxmm15DE$att == "Kept at\ncurrent level" | taxmm15DE$att == "Higher\nstandards" | taxmm15DE$att == "Organic\nstandards", "5", ifelse(
          taxmm15DE$att == "No\ncampaigns" | taxmm15DE$att == "Occasional\ncampaigns" | taxmm15DE$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm15DE$att == "No\ndiscounts" | taxmm15DE$att == "15% lower\nprices" | taxmm15DE$att == "30% lower\nprices", "6",
            "8")))))))

taxmm15DE$policy = factor(taxmm15DE$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 30% DE
taxmm30DE <- mm(subset(df_conj, country == "DE" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

taxmm30DE <- na.omit(taxmm30DE)
plot(taxmm30DE)

taxmm30DE$att <- factor(taxmm30DE$level, levels = c(rev(c("1) Increasing prices by 30%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("30% higher\nprices",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm30DE$policy <- ifelse(taxmm30DE$att == "No new tax" |  taxmm30DE$att == "Increasing prices by 15%" |  taxmm30DE$att == "30% higher\nprices", "1", ifelse(
  taxmm30DE$att == "General\nbudget" | taxmm30DE$att == "Env. & climate\nprotection" | taxmm30DE$att == "Low-income\nhouseholds" | taxmm30DE$att == "Reduce\nincome taxes" | taxmm30DE$att == "No tax revenues", "2", ifelse(
    taxmm30DE$att == "Keep at\ncurrent level" | taxmm30DE$att == "Halving\nsubsidies" | taxmm30DE$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm30DE$att == "No\nsuch rules" | taxmm30DE$att == "75%\nveg. meals" | taxmm30DE$att == "50%\nveg. meals" | taxmm30DE$att == "25%\nveg. meals" , "4", ifelse(
        taxmm30DE$att == "Kept at\ncurrent level" | taxmm30DE$att == "Higher\nstandards" | taxmm30DE$att == "Organic\nstandards", "5", ifelse(
          taxmm30DE$att == "No\ncampaigns" | taxmm30DE$att == "Occasional\ncampaigns" | taxmm30DE$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm30DE$att == "No\ndiscounts" | taxmm30DE$att == "15% lower\nprices" | taxmm30DE$att == "30% lower\nprices", "6",
            "8")))))))

taxmm30DE$policy = factor(taxmm30DE$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))

#rate 0% CN
taxmm0CN <- mm(subset(df_conj, country == "CN" & attrib1_lab %in% c("3) No new tax")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                 attrib4_lab + attrib6_lab, id = ~id, CNsign=CNsign, baselines = baselines_base)

taxmm0CN <- na.omit(taxmm0CN)
plot(taxmm0CN)

taxmm0CN$att <- factor(taxmm0CN$level, levels = c(rev(c("No new tax",
                                                        "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                        "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                        "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                        "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                        "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                        "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                       labels = c(rev(c("No new tax",
                                        "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                        "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                        "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                        "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                        "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                        "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm0CN$policy <- ifelse(taxmm0CN$att == "No new tax" |  taxmm0CN$att == "Increasing prices by 15%" |  taxmm0CN$att == "Increasing prices by 30%", "1", ifelse(
  taxmm0CN$att == "General\nbudget" | taxmm0CN$att == "Env. & climate\nprotection" | taxmm0CN$att == "Low-income\nhouseholds" | taxmm0CN$att == "Reduce\nincome taxes" | taxmm0CN$att == "No tax revenues", "2", ifelse(
    taxmm0CN$att == "Keep at\ncurrent level" | taxmm0CN$att == "Halving\nsubsidies" | taxmm0CN$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm0CN$att == "No\nsuch rules" | taxmm0CN$att == "75%\nveg. meals" | taxmm0CN$att == "50%\nveg. meals" | taxmm0CN$att == "25%\nveg. meals" , "4", ifelse(
        taxmm0CN$att == "Kept at\ncurrent level" | taxmm0CN$att == "Higher\nstandards" | taxmm0CN$att == "Organic\nstandards", "5", ifelse(
          taxmm0CN$att == "No\ncampaigns" | taxmm0CN$att == "Occasional\ncampaigns" | taxmm0CN$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm0CN$att == "No\ndiscounts" | taxmm0CN$att == "15% lower\nprices" | taxmm0CN$att == "30% lower\nprices", "6",
            "8")))))))

taxmm0CN$policy = factor(taxmm0CN$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 15% CN

table(df_conj$attrib1_lab, df_conj$country)
taxmm15CN <- mm(subset(df_conj, country == "CN" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, CNsign=CNsign, baselines = baselines_base)

taxmm15CN <- na.omit(taxmm15CN)
plot(taxmm15CN)

taxmm15CN$att <- factor(taxmm15CN$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm15CN$policy <- ifelse(taxmm15CN$att == "No new tax" |  taxmm15CN$att == "15% higher\nprices" |  taxmm15CN$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15CN$att == "General\nbudget" | taxmm15CN$att == "Env. & climate\nprotection" | taxmm15CN$att == "Low-income\nhouseholds" | taxmm15CN$att == "Reduce\nincome taxes" | taxmm15CN$att == "No tax revenues", "2", ifelse(
    taxmm15CN$att == "Keep at\ncurrent level" | taxmm15CN$att == "Halving\nsubsidies" | taxmm15CN$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm15CN$att == "No\nsuch rules" | taxmm15CN$att == "75%\nveg. meals" | taxmm15CN$att == "50%\nveg. meals" | taxmm15CN$att == "25%\nveg. meals" , "4", ifelse(
        taxmm15CN$att == "Kept at\ncurrent level" | taxmm15CN$att == "Higher\nstandards" | taxmm15CN$att == "Organic\nstandards", "5", ifelse(
          taxmm15CN$att == "No\ncampaigns" | taxmm15CN$att == "Occasional\ncampaigns" | taxmm15CN$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm15CN$att == "No\ndiscounts" | taxmm15CN$att == "15% lower\nprices" | taxmm15CN$att == "30% lower\nprices", "6",
            "8")))))))

taxmm15CN$policy = factor(taxmm15CN$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 30% CN
taxmm30CN <- mm(subset(df_conj, country == "CN" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, CNsign=CNsign, baselines = baselines_base)

taxmm30CN <- na.omit(taxmm30CN)
plot(taxmm30CN)

taxmm30CN$att <- factor(taxmm30CN$level, levels = c(rev(c("1) Increasing prices by 30%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm30CN$policy <- ifelse(taxmm30CN$att == "No new tax" |  taxmm30CN$att == "Increasing prices by 15%" |  taxmm30CN$att == "30% higher\nprices", "1", ifelse(
  taxmm30CN$att == "General\nbudget" | taxmm30CN$att == "Env. & climate\nprotection" | taxmm30CN$att == "Low-income\nhouseholds" | taxmm30CN$att == "Reduce\nincome taxes" | taxmm30CN$att == "No tax revenues", "2", ifelse(
    taxmm30CN$att == "Keep at\ncurrent level" | taxmm30CN$att == "Halving\nsubsidies" | taxmm30CN$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm30CN$att == "No\nsuch rules" | taxmm30CN$att == "75%\nveg. meals" | taxmm30CN$att == "50%\nveg. meals" | taxmm30CN$att == "25%\nveg. meals" , "4", ifelse(
        taxmm30CN$att == "Kept at\ncurrent level" | taxmm30CN$att == "Higher\nstandards" | taxmm30CN$att == "Organic\nstandards", "5", ifelse(
          taxmm30CN$att == "No\ncampaigns" | taxmm30CN$att == "Occasional\ncampaigns" | taxmm30CN$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm30CN$att == "No\ndiscounts" | taxmm30CN$att == "15% lower\nprices" | taxmm30CN$att == "30% lower\nprices", "6",
            "8")))))))

taxmm30CN$policy = factor(taxmm30CN$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))

#rate 0%
taxmm0US <- mm(subset(df_conj, country == "US" & attrib1_lab %in% c("3) No new tax")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                 attrib4_lab + attrib6_lab, id = ~id, USsign=USsign, baselines = baselines_base)

taxmm0US <- na.omit(taxmm0US)
plot(taxmm0US)

taxmm0US$att <- factor(taxmm0US$level, levels = c(rev(c("No new tax",
                                                        "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                        "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                        "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                        "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                        "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                        "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                       labels = c(rev(c("No new tax",
                                        "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                        "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                        "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                        "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                        "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                        "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm0US$policy <- ifelse(taxmm0US$att == "No new tax" |  taxmm0US$att == "Increasing prices by 15%" |  taxmm0US$att == "Increasing prices by 30%", "1", ifelse(
  taxmm0US$att == "General\nbudget" | taxmm0US$att == "Env. & climate\nprotection" | taxmm0US$att == "Low-income\nhouseholds" | taxmm0US$att == "Reduce\nincome taxes" | taxmm0US$att == "No tax revenues", "2", ifelse(
    taxmm0US$att == "Keep at\ncurrent level" | taxmm0US$att == "Halving\nsubsidies" | taxmm0US$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm0US$att == "No\nsuch rules" | taxmm0US$att == "75%\nveg. meals" | taxmm0US$att == "50%\nveg. meals" | taxmm0US$att == "25%\nveg. meals" , "4", ifelse(
        taxmm0US$att == "Kept at\ncurrent level" | taxmm0US$att == "Higher\nstandards" | taxmm0US$att == "Organic\nstandards", "5", ifelse(
          taxmm0US$att == "No\ncampaigns" | taxmm0US$att == "Occasional\ncampaigns" | taxmm0US$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm0US$att == "No\ndiscounts" | taxmm0US$att == "15% lower\nprices" | taxmm0US$att == "30% lower\nprices", "6",
            "8")))))))

taxmm0US$policy = factor(taxmm0US$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 15% US

table(df_conj$attrib1_lab, df_conj$country)
taxmm15US <- mm(subset(df_conj, country == "US" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, USsign=USsign, baselines = baselines_base)

taxmm15US <- na.omit(taxmm15US)
plot(taxmm15US)

taxmm15US$att <- factor(taxmm15US$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm15US$policy <- ifelse(taxmm15US$att == "No new tax" |  taxmm15US$att == "15% higher\nprices" |  taxmm15US$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15US$att == "General\nbudget" | taxmm15US$att == "Env. & climate\nprotection" | taxmm15US$att == "Low-income\nhouseholds" | taxmm15US$att == "Reduce\nincome taxes" | taxmm15US$att == "No tax revenues", "2", ifelse(
    taxmm15US$att == "Keep at\ncurrent level" | taxmm15US$att == "Halving\nsubsidies" | taxmm15US$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm15US$att == "No\nsuch rules" | taxmm15US$att == "75%\nveg. meals" | taxmm15US$att == "50%\nveg. meals" | taxmm15US$att == "25%\nveg. meals" , "4", ifelse(
        taxmm15US$att == "Kept at\ncurrent level" | taxmm15US$att == "Higher\nstandards" | taxmm15US$att == "Organic\nstandards", "5", ifelse(
          taxmm15US$att == "No\ncampaigns" | taxmm15US$att == "Occasional\ncampaigns" | taxmm15US$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm15US$att == "No\ndiscounts" | taxmm15US$att == "15% lower\nprices" | taxmm15US$att == "30% lower\nprices", "6",
            "8")))))))

taxmm15US$policy = factor(taxmm15US$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 30% US
taxmm30US <- mm(subset(df_conj, country == "US" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate_bin ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, USsign=USsign, baselines = baselines_base)

taxmm30US <- na.omit(taxmm30US)
plot(taxmm30US)

taxmm30US$att <- factor(taxmm30US$level, levels = c(rev(c("1) Increasing prices by 30%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "15% lower\nprices", "30% lower\nprices",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm30US$policy <- ifelse(taxmm30US$att == "No new tax" |  taxmm30US$att == "Increasing prices by 15%" |  taxmm30US$att == "30% higher\nprices", "1", ifelse(
  taxmm30US$att == "General\nbudget" | taxmm30US$att == "Env. & climate\nprotection" | taxmm30US$att == "Low-income\nhouseholds" | taxmm30US$att == "Reduce\nincome taxes" | taxmm30US$att == "No tax revenues", "2", ifelse(
    taxmm30US$att == "Keep at\ncurrent level" | taxmm30US$att == "Halving\nsubsidies" | taxmm30US$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm30US$att == "No\nsuch rules" | taxmm30US$att == "75%\nveg. meals" | taxmm30US$att == "50%\nveg. meals" | taxmm30US$att == "25%\nveg. meals" , "4", ifelse(
        taxmm30US$att == "Kept at\ncurrent level" | taxmm30US$att == "Higher\nstandards" | taxmm30US$att == "Organic\nstandards", "5", ifelse(
          taxmm30US$att == "No\ncampaigns" | taxmm30US$att == "Occasional\ncampaigns" | taxmm30US$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm30US$att == "No\ndiscounts" | taxmm30US$att == "15% lower\nprices" | taxmm30US$att == "30% lower\nprices", "6",
            "8")))))))

taxmm30US$policy = factor(taxmm30US$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))

#Plot marginal means figure

nrow((taxmm30CN))

df_taxmmt0 <- rbind(taxmm0DE, taxmm0US, taxmm0CN)
df_taxmmt0$tax <- rep(c("No new tax", "No new tax", "No new tax"), each=nrow(taxmm0DE))
df_taxmmt0$country <- rep(c("Germany", "USA", "China"), each=nrow(taxmm0DE))

df_taxmmt <- rbind(taxmm15DE, taxmm15US, taxmm15CN, taxmm30DE, taxmm30US, taxmm30CN)

df_taxmmt$tax <- rep(c("Increasing prices by 15%", "Increasing prices by 15%", "Increasing prices by 15%", "Increasing prices by 30%", "Increasing prices by 30%", "Increasing prices by 30%"), each=nrow(taxmm15DE))
df_taxmmt$country <- rep(c("Germany", "USA", "China", "Germany", "USA", "China"), each=nrow(taxmm15DE))

df_taxmmt_comp <- rbind(df_taxmmt0, df_taxmmt)

taxmm2 <- ggplot(subset(df_taxmmt_comp, policy=="Earmarking"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="bottom", axis.text.y=element_text(size=12), axis.title.y=element_text(size=16),
        legend.text=element_text(size=16), legend.title=element_text(size=16),
        strip.text.x = element_text(size = 16)) +
  ylab("Marginal Mean (Support Share)") +
  xlab("")+
  coord_cartesian(ylim = c(0.2, 0.8)) +
  scale_y_continuous(breaks = c(0.25, 0.5, 0.75), labels = c("25%", "50%", "75%")) +
  #geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 0.5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm2

legendtaxmm <- get_legend(taxmm2)
taxmm2 <- taxmm2 +
  theme(plot.title = element_text(size = 16, face = "bold"),strip.text.x = element_text(size=16, face ="bold"),axis.text.x =element_text(size=14, face ="bold"),strip.text.y = element_text(size=16, face ="bold"),axis.text.y =element_text(size=16, face ="bold"), axis.title.y = element_text(size = 16, face ="bold"), axis.title.x = element_text(size = 16, face ="bold"))+
  theme (legend.position = "none", legend.text =element_text(size=16, face ="bold"), legend.title = element_text(size=16, face ="bold"))


taxmm3 <- ggplot(subset(df_taxmmt_comp, policy=="Producer Subsidies"), aes(x=att, y = estimate, group =  tax, shape = tax, colour =  country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="bottom", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(0.2, 0.8)) +
  scale_y_continuous(breaks = c(0.25, 0.5, 0.75), labels = c("25%", "50%", "75%")) +
  #geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 0.5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")+ 
  theme(plot.title = element_text(size = 16, face = "bold"),strip.text.x = element_text(size=16, face ="bold"),axis.text.x =element_text(size=14, face ="bold"),strip.text.y = element_text(size=16, face ="bold"),axis.text.y =element_text(size=16, face ="bold"), axis.title.y = element_text(size = 16, face ="bold"), axis.title.x = element_text(size = 16, face ="bold"))+
  theme (legend.position = "bottom", legend.text =element_text(size=16, face ="bold"), legend.title = element_text(size=16, face ="bold"))

taxmm3


legendtaxmm <- get_legend(taxmm3)
taxmm3 <- taxmm3 + 
  theme(plot.title = element_text(size = 16, face = "bold"),strip.text.x = element_text(size=16, face ="bold"),axis.text.x =element_text(size=14, face ="bold"),strip.text.y = element_text(size=16, face ="bold"),axis.text.y =element_text(size=16, face ="bold"), axis.title.y = element_text(size = 16, face ="bold"), axis.title.x = element_text(size = 16, face ="bold"))+
  theme (legend.position = "none", legend.text =element_text(size=16, face ="bold"), legend.title = element_text(size=16, face ="bold"))


taxmm4 <- ggplot(subset(df_taxmmt_comp, policy=="Regulations"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(0.2, 0.8)) +
  scale_y_continuous(breaks = c(0.25, 0.5, 0.75), labels = c("25%", "50%", "75%")) +
  #geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 0.5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")+
  theme(plot.title = element_text(size = 16, face = "bold"),strip.text.x = element_text(size=16, face ="bold"),axis.text.x =element_text(size=14, face ="bold"),strip.text.y = element_text(size=16, face ="bold"),axis.text.y =element_text(size=16, face ="bold"), axis.title.y = element_text(size = 16, face ="bold"), axis.title.x = element_text(size = 16, face ="bold"))+
  theme (legend.position = "none", legend.text =element_text(size=16, face ="bold"), legend.title = element_text(size=16, face ="bold"))

taxmm4

taxmm5 <- ggplot(subset(df_taxmmt_comp, policy=="Standards"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_text(size=12), axis.title.y=element_text(size=16), strip.text.x = element_text(size = 16)) +
  ylab("Marginal Mean (Support Share)") +
  xlab("") +
  coord_cartesian(ylim = c(0.2, 0.8)) +
  scale_y_continuous(breaks = c(0.25, 0.5, 0.75), labels = c("25%", "50%", "75%")) +
  #geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 0.5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")+
  theme(plot.title = element_text(size = 16, face = "bold"),strip.text.x = element_text(size=16, face ="bold"),axis.text.x =element_text(size=14, face ="bold"),strip.text.y = element_text(size=16, face ="bold"),axis.text.y =element_text(size=16, face ="bold"), axis.title.y = element_text(size = 16, face ="bold"), axis.title.x = element_text(size = 16, face ="bold"))+
  theme (legend.position = "none", legend.text =element_text(size=16, face ="bold"), legend.title = element_text(size=16, face ="bold"))

taxmm5

taxmm6 <- ggplot(subset(df_taxmmt_comp, policy=="Campaigns"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(0.2, 0.8)) +
  scale_y_continuous(breaks = c(0.25, 0.5, 0.75), labels = c("25%", "50%", "75%")) +
  #geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 0.5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")+
  theme(plot.title = element_text(size = 16, face = "bold"),strip.text.x = element_text(size=16, face ="bold"),axis.text.x =element_text(size=14, face ="bold"),strip.text.y = element_text(size=16, face ="bold"),axis.text.y =element_text(size=13, face ="bold"), axis.title.y = element_text(size = 16, face ="bold"), axis.title.x = element_text(size = 16, face ="bold"))+
  theme (legend.position = "none", legend.text =element_text(size=16, face ="bold"), legend.title = element_text(size=16, face ="bold"))

taxmm6

taxmm7 <- ggplot(subset(df_taxmmt_comp, policy=="Discounts"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(0.2, 0.8)) +
  scale_y_continuous(breaks = c(0.25, 0.5, 0.75), labels = c("25%", "50%", "75%")) +
  #geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 0.5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")+
  theme(plot.title = element_text(size = 16, face = "bold"),strip.text.x = element_text(size=16, face ="bold"),axis.text.x =element_text(size=14, face ="bold"),strip.text.y = element_text(size=16, face ="bold"),axis.text.y =element_text(size=16, face ="bold"), axis.title.y = element_text(size = 16, face ="bold"), axis.title.x = element_text(size = 16, face ="bold"))+
  theme (legend.position = "none", legend.text =element_text(size=16, face ="bold"), legend.title = element_text(size=16, face ="bold"))

taxmm7


fig_taxmm1 <- ggdraw() +
  draw_plot(taxmm2, x = 0, y = 0.52, width = 0.34, height = 0.48) +
  draw_plot(taxmm3, x = 0.34, y = 0.52, width = 0.33, height = 0.48) +
  draw_plot(taxmm4, x = 0.67, y = 0.52, width = 0.33, height = 0.48) +
  draw_plot(taxmm5, x = 0, y = 0.04, width = 0.34, height = 0.48) +
  draw_plot(taxmm6, x = 0.34, y = 0.04, width = 0.33, height = 0.48) +
  draw_plot(taxmm7, x = 0.67, y = 0.04, width = 0.33, height = 0.48) +
  draw_plot(legendtaxmm, x = 0, y = 0, width = 1, height = 0.04)
fig_taxmm1

ggsave(filename = "./fig_taxmm1.pdf", fig_taxmm1, width = 19, height = 9, dpi=320)


################## SI Figures 1b  ###############

################## Marginal Means by tax: rate as DV ###############
#rate 15% DE

table(df_conj$attrib1_lab, df_conj$country)
taxmm15DE <- mm(subset(df_conj, country == "DE" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

taxmm15DE <- na.omit(taxmm15DE)
plot(taxmm15DE)

taxmm15DE$att <- factor(taxmm15DE$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "Reducing prices\nby 15%", "Reducing prices\nby 30%",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm15DE$policy <- ifelse(taxmm15DE$att == "No new tax" |  taxmm15DE$att == "Increasing prices by 15%" |  taxmm15DE$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15DE$att == "General\nbudget" | taxmm15DE$att == "Env. & climate\nprotection" | taxmm15DE$att == "Low-income\nhouseholds" | taxmm15DE$att == "Reduce\nincome taxes" | taxmm15DE$att == "No tax revenues", "2", ifelse(
    taxmm15DE$att == "Keep at\ncurrent level" | taxmm15DE$att == "Halving\nsubsidies" | taxmm15DE$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm15DE$att == "No\nsuch rules" | taxmm15DE$att == "75%\nveg. meals" | taxmm15DE$att == "50%\nveg. meals" | taxmm15DE$att == "25%\nveg. meals" , "4", ifelse(
        taxmm15DE$att == "Kept at\ncurrent level" | taxmm15DE$att == "Higher\nstandards" | taxmm15DE$att == "Organic\nstandards", "5", ifelse(
          taxmm15DE$att == "No\ncampaigns" | taxmm15DE$att == "Occasional\ncampaigns" | taxmm15DE$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm15DE$att == "No\ndiscounts" | taxmm15DE$att == "Reducing prices\nby 15%" | taxmm15DE$att == "Reducing prices\nby 30%", "6",
            "8")))))))

taxmm15DE$policy = factor(taxmm15DE$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 30% DE
taxmm30DE <- mm(subset(df_conj, country == "DE" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

taxmm30DE <- na.omit(taxmm30DE)
plot(taxmm30DE)

taxmm30DE$att <- factor(taxmm30DE$level, levels = c(rev(c("1) Increasing prices by 30%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "Reducing prices\nby 15%", "Reducing prices\nby 30%",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm30DE$policy <- ifelse(taxmm30DE$att == "No new tax" |  taxmm30DE$att == "Increasing prices by 15%" |  taxmm30DE$att == "Increasing prices by 30%", "1", ifelse(
  taxmm30DE$att == "General\nbudget" | taxmm30DE$att == "Env. & climate\nprotection" | taxmm30DE$att == "Low-income\nhouseholds" | taxmm30DE$att == "Reduce\nincome taxes" | taxmm30DE$att == "No tax revenues", "2", ifelse(
    taxmm30DE$att == "Keep at\ncurrent level" | taxmm30DE$att == "Halving\nsubsidies" | taxmm30DE$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm30DE$att == "No\nsuch rules" | taxmm30DE$att == "75%\nveg. meals" | taxmm30DE$att == "50%\nveg. meals" | taxmm30DE$att == "25%\nveg. meals" , "4", ifelse(
        taxmm30DE$att == "Kept at\ncurrent level" | taxmm30DE$att == "Higher\nstandards" | taxmm30DE$att == "Organic\nstandards", "5", ifelse(
          taxmm30DE$att == "No\ncampaigns" | taxmm30DE$att == "Occasional\ncampaigns" | taxmm30DE$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm30DE$att == "No\ndiscounts" | taxmm30DE$att == "Reducing prices\nby 15%" | taxmm30DE$att == "Reducing prices\nby 30%", "6",
            "8")))))))

taxmm30DE$policy = factor(taxmm30DE$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))

#rate 15% CN

table(df_conj$attrib1_lab, df_conj$country)
taxmm15CN <- mm(subset(df_conj, country == "CN" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, CNsign=CNsign, baselines = baselines_base)

taxmm15CN <- na.omit(taxmm15CN)
plot(taxmm15CN)

taxmm15CN$att <- factor(taxmm15CN$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "Reducing prices\nby 15%", "Reducing prices\nby 30%",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm15CN$policy <- ifelse(taxmm15CN$att == "No new tax" |  taxmm15CN$att == "Increasing prices by 15%" |  taxmm15CN$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15CN$att == "General\nbudget" | taxmm15CN$att == "Env. & climate\nprotection" | taxmm15CN$att == "Low-income\nhouseholds" | taxmm15CN$att == "Reduce\nincome taxes" | taxmm15CN$att == "No tax revenues", "2", ifelse(
    taxmm15CN$att == "Keep at\ncurrent level" | taxmm15CN$att == "Halving\nsubsidies" | taxmm15CN$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm15CN$att == "No\nsuch rules" | taxmm15CN$att == "75%\nveg. meals" | taxmm15CN$att == "50%\nveg. meals" | taxmm15CN$att == "25%\nveg. meals" , "4", ifelse(
        taxmm15CN$att == "Kept at\ncurrent level" | taxmm15CN$att == "Higher\nstandards" | taxmm15CN$att == "Organic\nstandards", "5", ifelse(
          taxmm15CN$att == "No\ncampaigns" | taxmm15CN$att == "Occasional\ncampaigns" | taxmm15CN$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm15CN$att == "No\ndiscounts" | taxmm15CN$att == "Reducing prices\nby 15%" | taxmm15CN$att == "Reducing prices\nby 30%", "6",
            "8")))))))

taxmm15CN$policy = factor(taxmm15CN$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 30% CN
taxmm30CN <- mm(subset(df_conj, country == "CN" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, CNsign=CNsign, baselines = baselines_base)

taxmm30CN <- na.omit(taxmm30CN)
plot(taxmm30CN)

taxmm30CN$att <- factor(taxmm30CN$level, levels = c(rev(c("1) Increasing prices by 30%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "Reducing prices\nby 15%", "Reducing prices\nby 30%",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm30CN$policy <- ifelse(taxmm30CN$att == "No new tax" |  taxmm30CN$att == "Increasing prices by 15%" |  taxmm30CN$att == "Increasing prices by 30%", "1", ifelse(
  taxmm30CN$att == "General\nbudget" | taxmm30CN$att == "Env. & climate\nprotection" | taxmm30CN$att == "Low-income\nhouseholds" | taxmm30CN$att == "Reduce\nincome taxes" | taxmm30CN$att == "No tax revenues", "2", ifelse(
    taxmm30CN$att == "Keep at\ncurrent level" | taxmm30CN$att == "Halving\nsubsidies" | taxmm30CN$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm30CN$att == "No\nsuch rules" | taxmm30CN$att == "75%\nveg. meals" | taxmm30CN$att == "50%\nveg. meals" | taxmm30CN$att == "25%\nveg. meals" , "4", ifelse(
        taxmm30CN$att == "Kept at\ncurrent level" | taxmm30CN$att == "Higher\nstandards" | taxmm30CN$att == "Organic\nstandards", "5", ifelse(
          taxmm30CN$att == "No\ncampaigns" | taxmm30CN$att == "Occasional\ncampaigns" | taxmm30CN$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm30CN$att == "No\ndiscounts" | taxmm30CN$att == "Reducing prices\nby 15%" | taxmm30CN$att == "Reducing prices\nby 30%", "6",
            "8")))))))

taxmm30CN$policy = factor(taxmm30CN$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))

#rate 15% US

table(df_conj$attrib1_lab, df_conj$country)
taxmm15US <- mm(subset(df_conj, country == "US" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, USsign=USsign, baselines = baselines_base)

taxmm15US <- na.omit(taxmm15US)
plot(taxmm15US)

taxmm15US$att <- factor(taxmm15US$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "Reducing prices\nby 15%", "Reducing prices\nby 30%",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm15US$policy <- ifelse(taxmm15US$att == "No new tax" |  taxmm15US$att == "Increasing prices by 15%" |  taxmm15US$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15US$att == "General\nbudget" | taxmm15US$att == "Env. & climate\nprotection" | taxmm15US$att == "Low-income\nhouseholds" | taxmm15US$att == "Reduce\nincome taxes" | taxmm15US$att == "No tax revenues", "2", ifelse(
    taxmm15US$att == "Keep at\ncurrent level" | taxmm15US$att == "Halving\nsubsidies" | taxmm15US$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm15US$att == "No\nsuch rules" | taxmm15US$att == "75%\nveg. meals" | taxmm15US$att == "50%\nveg. meals" | taxmm15US$att == "25%\nveg. meals" , "4", ifelse(
        taxmm15US$att == "Kept at\ncurrent level" | taxmm15US$att == "Higher\nstandards" | taxmm15US$att == "Organic\nstandards", "5", ifelse(
          taxmm15US$att == "No\ncampaigns" | taxmm15US$att == "Occasional\ncampaigns" | taxmm15US$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm15US$att == "No\ndiscounts" | taxmm15US$att == "Reducing prices\nby 15%" | taxmm15US$att == "Reducing prices\nby 30%", "6",
            "8")))))))

taxmm15US$policy = factor(taxmm15US$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))


#rate 30% US
taxmm30US <- mm(subset(df_conj, country == "US" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                  attrib4_lab + attrib6_lab, id = ~id, USsign=USsign, baselines = baselines_base)

taxmm30US <- na.omit(taxmm30US)
plot(taxmm30US)

taxmm30US$att <- factor(taxmm30US$level, levels = c(rev(c("1) Increasing prices by 30%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "4) No such rules", "1) At least 75% vegetarian meals", "2) At least 50% vegetarian meals", "3) At least 25% vegetarian meals", 
                                                          "1)\tOrganic practices (no antibiotics/chemicals) & no cages", "2) Stringent limits on antibiotics/chemicals & large cages", "3) Standards kept at current level",
                                                          "3) No discounts", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\nbudget", "Env. & climate\nprotection", "Low-income\nhouseholds", "Reduce\nincome taxes",
                                         "Keep at\ncurrent level", "Halving\nsubsidies", "Eliminating\nsubsidies",
                                         "No\nsuch rules", "75%\nveg. meals", "50%\nveg. meals", "25%\nveg. meals", 
                                         "Organic\nstandards", "Higher\nstandards", "Kept at\ncurrent level",
                                         "No\ndiscounts", "Reducing prices\nby 15%", "Reducing prices\nby 30%",
                                         "No\ncampaigns", "Occasional\ncampaigns", "Frequent\ncampaigns"))))


taxmm30US$policy <- ifelse(taxmm30US$att == "No new tax" |  taxmm30US$att == "Increasing prices by 15%" |  taxmm30US$att == "Increasing prices by 30%", "1", ifelse(
  taxmm30US$att == "General\nbudget" | taxmm30US$att == "Env. & climate\nprotection" | taxmm30US$att == "Low-income\nhouseholds" | taxmm30US$att == "Reduce\nincome taxes" | taxmm30US$att == "No tax revenues", "2", ifelse(
    taxmm30US$att == "Keep at\ncurrent level" | taxmm30US$att == "Halving\nsubsidies" | taxmm30US$att == "Eliminating\nsubsidies", "3", ifelse(
      taxmm30US$att == "No\nsuch rules" | taxmm30US$att == "75%\nveg. meals" | taxmm30US$att == "50%\nveg. meals" | taxmm30US$att == "25%\nveg. meals" , "4", ifelse(
        taxmm30US$att == "Kept at\ncurrent level" | taxmm30US$att == "Higher\nstandards" | taxmm30US$att == "Organic\nstandards", "5", ifelse(
          taxmm30US$att == "No\ncampaigns" | taxmm30US$att == "Occasional\ncampaigns" | taxmm30US$att == "Frequent\ncampaigns", "7", ifelse(
            taxmm30US$att == "No\ndiscounts" | taxmm30US$att == "Reducing prices\nby 15%" | taxmm30US$att == "Reducing prices\nby 30%", "6",
            "8")))))))

taxmm30US$policy = factor(taxmm30US$policy, levels=c(1:8), labels=c("Taxes","Earmarking","Producer Subsidies", "Regulations", "Standards", "Discounts", "Campaigns", "Other"))

#Plot marginal means figure

df_taxmmt <- rbind(taxmm15DE, taxmm15US, taxmm15CN, taxmm30DE, taxmm30US, taxmm30CN)
df_taxmmt$tax <- rep(c("Increasing prices by 15%", "Increasing prices by 15%", "Increasing prices by 15%", "Increasing prices by 30%", "Increasing prices by 30%", "Increasing prices by 30%"), each=nrow(taxmm15DE))
df_taxmmt$country <- rep(c("Germany", "USA", "China", "Germany", "USA", "China"), each=nrow(taxmm15DE))

taxmm2 <- ggplot(subset(df_taxmmt, policy=="Earmarking"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="bottom", axis.text.y=element_text(size=12), axis.title.y=element_text(size=16),
        legend.text=element_text(size=16), legend.title=element_text(size=16),
        strip.text.x = element_text(size = 16)) +
  ylab("Marginal Mean (Support Rating)") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm2

legendtaxmm <- get_legend(taxmm2)
taxmm2 <- taxmm2 + theme(legend.position="none")

taxmm3 <- ggplot(subset(df_taxmmt, policy=="Producer Subsidies"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm3

taxmm4 <- ggplot(subset(df_taxmmt, policy=="Regulations"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm4

taxmm5 <- ggplot(subset(df_taxmmt, policy=="Standards"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_text(size=12), axis.title.y=element_text(size=16), strip.text.x = element_text(size = 16)) +
  ylab("Marginal Mean (Support Rating)") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm5

taxmm6 <- ggplot(subset(df_taxmmt, policy=="Campaigns"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm6

taxmm7 <- ggplot(subset(df_taxmmt, policy=="Discounts"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm7


fig_taxmm2 <- ggdraw() +
  draw_plot(taxmm2, x = 0, y = 0.52, width = 0.34, height = 0.48) +
  draw_plot(taxmm3, x = 0.34, y = 0.52, width = 0.33, height = 0.48) +
  draw_plot(taxmm4, x = 0.67, y = 0.52, width = 0.33, height = 0.48) +
  draw_plot(taxmm5, x = 0, y = 0.04, width = 0.34, height = 0.48) +
  draw_plot(taxmm6, x = 0.34, y = 0.04, width = 0.33, height = 0.48) +
  draw_plot(taxmm7, x = 0.67, y = 0.04, width = 0.33, height = 0.48) +
  draw_plot(legendtaxmm, x = 0, y = 0, width = 1, height = 0.04)
fig_taxmm2


####### Rating overview (with 95% confidence interval)--------------

rateavrg <- aggregate(rate ~ attrib1_lab +  attrib2_lab +  attrib3_lab +  attrib4_lab +  
                        attrib5_lab +  attrib6_lab +  attrib7_lab + country, data=subset(df_conj), mean)

fig_rate_average <- ggplot(rateavrg, aes(x=rate, colour=country)) + 
  geom_density(size=1.2) + 
  theme_bw() +
  theme(panel.grid.major.x = element_line(size=.5, color="gray80"),
        panel.grid.minor.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.y = element_line(size=.5, color="gray80" )) +
  xlab("Distribution of average ratings for policy-packages") +
  ylab("Density") +
  scale_colour_manual(values = c("US" = "#b2abd2", "DE" = "#5e3c99", "CN" = "#e66101")) +
  scale_x_continuous(breaks = c(1,2,3,4,5,6,7), labels = c("1","2", "3", "4", "5", "6", "7")) +
  coord_cartesian(ylim = c(.0257, 0.55), xlim = c(1.27, 6.73)) +
  theme (legend.position ="right",legend.text =element_text(size=12, face ="bold"), legend.title = element_blank() )+
  theme(plot.title = element_text(size = 14, face = "bold"),axis.text.x =element_text(size=12, face ="bold"),axis.text.y =element_text(size=12, face ="bold"),strip.text.x = element_text(size=14, face ="bold"), axis.title.y = element_text(size = 14, face ="bold"), axis.title.x = element_text(size = 14, face ="bold"))


ggsave(".fig_rate_average.jpeg", fig_rate_average,  width = 12, height = 12)

##########################################Tables: Main Results and Robustness Checks#####################################

table_fig1_CN <- summary.amce(r_bin_base_CN)
table_fig1_DE <- summary.amce(r_bin_base_DE)
table_fig1_US <- summary.amce(r_bin_base_US)

table_fig1_CN_control <- summary.amce(r_bin_base_control_CN)
table_fig1_DE_control <- summary.amce(r_bin_base_control_DE)
table_fig1_US_control <- summary.amce(r_bin_base_control_US)

table_fig1_DE_robust_high <- summary.amce(r_bin_base_robust_high_DE)
table_fig1_US_robust_high <- summary.amce(r_bin_base_robust_high_US)

table_fig1_DE_robust_low <- summary.amce(r_bin_base_robust_low_DE)
table_fig1_US_robust_low <- summary.amce(r_bin_base_robust_low_US)

table_fig1_DE_robust <- summary.amce(r_bin_base_robust_DE)
table_fig1_CN_robust <- summary.amce(r_bin_base_robust_CN)
table_fig1_US_robust <- summary.amce(r_bin_base_robust_US)

table_fig1_DE_robust_high <- summary.amce(r_bin_base_robust_high_DE)
table_fig1_US_robust_high <- summary.amce(r_bin_base_robust_high_US)

table_fig1_US_robust_meat <- summary.amce(r_bin_base_robust_meat_US)
table_fig1_US_robust_meat_high$amce[3:6] <- round(table_fig1_US_robust_meat_high$amce[3:6], digits=4)

table_fig1_US_robust_no_meat <- summary.amce(r_bin_base_robust_no_meat_US)
table_fig1_US_robust_meat_$amce[3:6] <- round(table_fig1_US_robust_meat$amce[3:6], digits=4)

table_fig1_DE_robust_meat <- summary.amce(r_bin_base_robust_meat_DE)
table_fig1_DE_robust_meat$amce[3:6] <- round(table_fig1_DE_robust_meat$amce[3:6], digits=4)

table_fig1_DE_robust_no_meat <- summary.amce(r_bin_base_robust_no_meat_DE)
table_fig1_DE_robust_no_meat_high$amce[3:6] <- round(table_fig1_DE_robust_no_meat_high$amce[3:6], digits=4)

table_fig1_CN_robust_meat <- summary.amce(r_bin_base_robust_meat_CN)
table_fig1_CN_robust_meat$amce[3:6] <- round(table_fig1_CN_robust_meat$amce[3:6], digits=4)

table_fig1_CN_robust_no_meat <- summary.amce(r_bin_base_robust_no_meat_CN)
table_fig1_CN_robust_no_meat$amce[3:6] <- round(table_fig1_CN_robust_no_meat$amce[3:6], digits=4)

table_fig1_US_robust_meat_high <- summary.amce(r_bin_base_robust_meat_high_US)
table_fig1_US_robust_meat_high$amce[3:6] <- round(table_fig1_US_robust_meat_high$amce[3:6], digits=4)

table_fig1_US_robust_meat_low <- summary.amce(r_bin_base_robust_meat_low_US)
table_fig1_US_robust_meat_low$amce[3:6] <- round(table_fig1_US_robust_meat_low$amce[3:6], digits=4)

table_fig1_DE_robust_meat_high <- summary.amce(r_bin_base_robust_meat_high_DE)
table_fig1_DE_robust_meat_high$amce[3:6] <- round(table_fig1_DE_robust_meat_high$amce[3:6], digits=4)

table_fig1_DE_robust_meat_low <- summary.amce(r_bin_base_robust_meat_low_DE)
table_fig1_DE_robust_meat_low$amce[3:6] <- round(table_fig1_DE_robust_meat_low$amce[3:6], digits=4)

table_fig1_CN_robust_meat_high <- summary.amce(r_bin_base_robust_meat_high_CN)
table_fig1_CN_robust_meat_high$amce[3:6] <- round(table_fig1_CN_robust_meat_high$amce[3:6], digits=4)

table_fig1_CN_robust_meat_low <- summary.amce(r_bin_base_robust_meat_low_CN)
table_fig1_CN_robust_meat_low$amce[3:6] <- round(table_fig1_CN_robust_meat_low$amce[3:6], digits=4)


table_fig1_DE_robust_left <- summary.amce(r_bin_base_robust_left_DE)
table_fig1_DE_robust_left$amce[3:6] <- round(table_fig1_DE_robust_left$amce[3:6], digits=4)

table_fig1_DE_robust_right <- summary.amce(r_bin_base_robust_right_DE)
table_fig1_DE_robust_right$amce[3:6] <- round(table_fig1_DE_robust_right$amce[3:6], digits=4)

table_fig1_US_robust_left <- summary.amce(r_bin_base_robust_left_US)
table_fig1_US_robust_left$amce[3:6] <- round(table_fig1_US_robust_left$amce[3:6], digits=4)

table_fig1_US_robust_right <- summary.amce(r_bin_base_robust_right_US)
table_fig1_US_robust_right$amce[3:6] <- round(table_fig1_US_robust_right$amce[3:6], digits=4)

table_fig1_DE_robust_too_much <- summary.amce(r_bin_base_robust_too_much_DE)
table_fig1_DE_robust_too_much$amce[3:6] <- round(table_fig1_DE_robust_too_much$amce[3:6], digits=4)

table_fig1_DE_robust_too_little <- summary.amce(r_bin_base_robust_too_little_DE)
table_fig1_DE_robust_too_little$amce[3:6] <- round(table_fig1_DE_robust_too_little$amce[3:6], digits=4)

table_fig1_US_robust_too_much <- summary.amce(r_bin_base_robust_too_much_US)
table_fig1_US_robust_too_much$amce[3:6] <- round(table_fig1_US_robust_too_much$amce[3:6], digits=4)

table_fig1_US_robust_too_little <- summary.amce(r_bin_base_robust_too_little_US)
table_fig1_US_robust_too_little$amce[3:6] <- round(table_fig1_US_robust_too_little$amce[3:6], digits=4)

table_fig1_US_robust_Republican <- summary.amce(r_bin_base_robust_Republican_US)
table_fig1_US_robust_Republican$amce[3:6] <- round(table_fig1_US_robust_Republican$amce[3:6], digits=4)

table_fig1_US_robust_Democrat <- summary.amce(r_bin_base_robust_Democrat_US)
table_fig1_US_robust_Democrat$amce[3:6] <- round(table_fig1_US_robust_Democrat$amce[3:6], digits=4)

table_fig1_US_robust_Independent <- summary.amce(r_bin_base_robust_Independent_US)
table_fig1_US_robust_Independent$amce[3:6] <- round(table_fig1_US_robust_Independent$amce[3:6], digits=4)


lapply(table_fig1_CN, function(x) write.table( data.frame(x), 'table_fig1_CN.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE, function(x) write.table( data.frame(x), 'table_fig1_DE.csv'  , append= T, sep=',' ))
lapply(table_fig1_US, function(x) write.table( data.frame(x), 'table_fig1_US.csv'  , append= T, sep=',' ))
lapply(table_fig1_CN_control, function(x) write.table( data.frame(x), 'table_fig1_CN_control.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_control, function(x) write.table( data.frame(x), 'table_fig1_DE_control.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_control, function(x) write.table( data.frame(x), 'table_fig1_US_control.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust_high, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_high.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_high, function(x) write.table( data.frame(x), 'table_fig1_US_robust_high.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust_low, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_low.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_low, function(x) write.table( data.frame(x), 'table_fig1_US_robust_low.csv'  , append= T, sep=',' ))
lapply(table_fig1_CN_robust, function(x) write.table( data.frame(x), 'table_fig1_CN_robust.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust, function(x) write.table( data.frame(x), 'table_fig1_DE_robust.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust, function(x) write.table( data.frame(x), 'table_fig1_US_robust.csv'  , append= T, sep=',' ))

lapply(table_fig1_US_robust_left, function(x) write.table( data.frame(x), 'table_fig1_US_robust_left.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_right, function(x) write.table( data.frame(x), 'table_fig1_US_robust_right.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_too_much, function(x) write.table( data.frame(x), 'table_fig1_US_robust_too_much.csv'  , append= T, sep=';' ))
lapply(table_fig1_US_robust_too_little, function(x) write.table( data.frame(x), 'table_fig1_US_robust_too_little.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_Republican, function(x) write.table( data.frame(x), 'table_fig1_US_robust_Republican.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_Democrat, function(x) write.table( data.frame(x), 'table_fig1_US_robust_Democrat.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_Independent, function(x) write.table( data.frame(x), 'table_fig1_US_robust_Independent.csv'  , append= T, sep=',' ))

lapply(table_fig1_DE_robust_left, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_left.csv'  , append= T, sep=';' ))
lapply(table_fig1_DE_robust_right, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_right.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust_too_much, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_too_much.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust_too_little, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_too_little.csv'  , append= T, sep=',' ))

lapply(table_fig1_CN_robust_meat, function(x) write.table( data.frame(x), 'table_fig1_CN_robust_meat.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust_meat, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_meat.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_meat, function(x) write.table( data.frame(x), 'table_fig1_US_robust_meat.csv'  , append= T, sep=',' ))

lapply(table_fig1_CN_robust_meat_high, function(x) write.table( data.frame(x), 'table_fig1_CN_robust_meat_high.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust_meat_high, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_meat_high.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_meat_high, function(x) write.table( data.frame(x), 'table_fig1_US_robust_meat_high.csv'  , append= T, sep=',' ))

lapply(table_fig1_CN_robust_meat_low, function(x) write.table( data.frame(x), 'table_fig1_CN_robust_meat_low.csv'  , append= T, sep=',' ))
lapply(table_fig1_DE_robust_meat_low, function(x) write.table( data.frame(x), 'table_fig1_DE_robust_meat_low.csv'  , append= T, sep=',' ))
lapply(table_fig1_US_robust_meat_low, function(x) write.table( data.frame(x), 'table_fig1_US_robust_meat_low.csv'  , append= T, sep=',' ))
